From asi
Annotates codebases with dimensional analysis comments on units, dimensions, and decimal scaling. Prevents mismatches and catches arithmetic bugs in DeFi protocols, offchain code, and numeric computations.
npx claudepluginhub plurigrid/asi --plugin asiThis skill is limited to using the following tools:
This skill orchestrates a dimensional-analysis pipeline for codebases that perform numeric computations with mixed units, precisions, or scaling factors. The main skill context is a workflow controller only: it delegates scanning, vocabulary discovery, annotation, propagation, and validation to specialized subagents, then manages batching, persistence, retries, coverage gates, and final reporting.
Annotates codebases with dimensional analysis comments documenting units, dimensions, and decimal scaling. Audits DeFi protocols and arithmetic code for mismatches and bugs.
Proactively hunts bugs by assessing codebase risks via complexity, coverage gaps, and structural analysis, then writes reproducing tests for high-risk hotspots. Use before releases for confirmed issues.
Runs cross-codebase quality audits using parallel specialist agents (QA, Hacker, Performance presets) for systemic bug detection after major features or periodically.
Share bugs, ideas, or general feedback.
This skill orchestrates a dimensional-analysis pipeline for codebases that perform numeric computations with mixed units, precisions, or scaling factors. The main skill context is a workflow controller only: it delegates scanning, vocabulary discovery, annotation, propagation, and validation to specialized subagents, then manages batching, persistence, retries, coverage gates, and final reporting.
D18{tok}, D27{UoA/tok})This skill runs in one mode only: full-auto.
This is a workflow-based skill that delegates step-specific work to specialized agents via the Task tool. You orchestrate the overall process, manage coverage and state persistence, and ensure that every in-scope file is processed through each step of the pipeline.
When you start a step, report it:
Starting Step: Step {n}
This skill must audit all in-scope arithmetic files, including large repositories.
files array), across all priority tiers (CRITICAL, HIGH, MEDIUM, LOW).arithmetic-scanner persists the in-scope file manifest to DIMENSIONAL_SCOPE.json in the project root, and that manifest is the source of truth for Steps 2-4.step2: anchor annotation completed (or explicit no-anchor result)step3: propagation completed (or explicit no-propagation result)step4: validation completeddimension-discoverer persists the discovered dimensional vocabulary to DIMENSIONAL_UNITS.md in the project root for reuse by later steps and future runs.BLOCKED state, persist the blocking reason and retry count in DIMENSIONAL_SCOPE.json and reflect the same file in coverage.unprocessed_files.arithmetic-scanner owns repository scanning, arithmetic-file prioritization, and writing DIMENSIONAL_SCOPE.json.dimension-discoverer owns dimensional vocabulary discovery, unit inference, and writing DIMENSIONAL_UNITS.md.dimension-annotator owns annotation format decisions, anchor-point edits, and comment-writing behavior.dimension-propagator owns propagation logic, inferred annotations, and mismatch reporting during tracing.dimension-validator owns bug detection, red-flag evaluation, rationalization rejection, and confirmation or refutation of propagated mismatches.Follow these sections in order. Do not advance until the current step satisfies its completion gate.
DIMENSIONAL_SCOPE.json and DIMENSIONAL_UNITS.md live in the project root.DIMENSIONAL_SCOPE.json.in_scope_files is the source of truth for Steps 2-4. Never derive later scope from discovery-only inputs.BLOCKED, persist the matching step*_reason and step*_retry_count fields on the file entry in DIMENSIONAL_SCOPE.json.coverage.unprocessed_files must be derived from terminal BLOCKED entries in DIMENSIONAL_SCOPE.json using { "path": "...", "blocked_step": "step2|step3|step4", "reason": "...", "retry_count": 1 }.BLOCKED file once with a focused prompt. If it is still BLOCKED, keep the documented reason and continue. Do not finalize while any file remains PENDING.If cached artifacts cannot be reused, delegate repository scanning to arithmetic-scanner and vocabulary discovery to dimension-discoverer. Do not do that step-specific analysis directly in the main skill context.
DIMENSIONAL_UNITS.md and DIMENSIONAL_SCOPE.json already exist in the project root.DIMENSIONAL_SCOPE.json.project_root matches the current repo rootDIMENSIONAL_SCOPE.json contains in_scope_files, discoverer_focus_files, recommended_discovery_order, and per-file step2, step3, step4 fieldsDIMENSIONAL_UNITS.md is a usable dimensional vocabulary for this repoin_scope_files is empty, skip Steps 2-4 and produce final output with zero findings.Task tool to spawn the arithmetic-scanner agent. Its prompt must include:
DIMENSIONAL_SCOPE.jsonDIMENSIONAL_SCOPE.json with project_root, in_scope_files, discoverer_focus_files, and recommended_discovery_orderstep2: "PENDING", step3: "PENDING", and step4: "PENDING"discoverer_focus_files to CRITICAL/HIGH when more than 50 arithmetic files are found, while keeping all priorities in in_scope_filesDIMENSIONAL_SCOPE.json from disk and confirm it exists and contains the required Step 1 fields before continuing.Task tool to spawn the dimension-discoverer agent. Its prompt must include:
DIMENSIONAL_SCOPE.jsonDIMENSIONAL_UNITS.mddiscoverer_focus_files with each file's path, priority, score, and categoryrecommended_discovery_orderDIMENSIONAL_SCOPE.json as the Step 1 source of truth and write DIMENSIONAL_UNITS.md with Base Units, Derived Units, and Precision Prefixes sections. If in_scope_files is empty, it must still write the same headings with empty sections.in_scope_files is empty after the discoverer writes DIMENSIONAL_UNITS.md, skip Steps 2-4 and produce final output with zero findings.The main skill context must not add annotations itself. Use the Task tool to spawn dimension-annotator agents for all anchor-point annotation work. For full examples and annotation format details, see [{baseDir}/references/annotate.md]({baseDir}/references/annotate.md).
DIMENSIONAL_SCOPE.json and build batches from in_scope_files. Every in-scope file, including MEDIUM and LOW priority files, must receive a Step 2 outcome.<= 10 files: one batch11-30 files: one batch per category> 30 files: one batch per category, splitting categories larger than 10 files into sub-batches of about 8 filesstep2 = "PENDING" for every in-scope file and persist the updated DIMENSIONAL_SCOPE.json.DIMENSIONAL_UNITS.mdDIMENSIONAL_SCOPE.jsonANNOTATED, REVIEWED_NO_ANCHOR_CHANGES, or BLOCKED plus a one-line justificationANNOTATEDREVIEWED_NO_ANCHOR_CHANGESBLOCKEDBLOCKED, also persist step2_reason and step2_retry_count. Retry each BLOCKED file once with a focused prompt.PENDING in on-disk manifest state.The main skill context must not perform propagation reasoning itself. Use the Task tool to spawn dimension-propagator agents to extend annotations through arithmetic, function calls, and assignments. For algebra details, see [{baseDir}/references/dimension-algebra.md]({baseDir}/references/dimension-algebra.md).
DIMENSIONAL_SCOPE.json and build propagation batches from in_scope_files. Every in-scope file must receive a Step 3 outcome.step3 = "PENDING" for every in-scope file and persist the updated manifest.DIMENSIONAL_UNITS.mdDIMENSIONAL_SCOPE.jsonPROPAGATED, REVIEWED_NO_PROPAGATION_CHANGES, or BLOCKED plus a one-line justificationPROPAGATEDREVIEWED_NO_PROPAGATION_CHANGESBLOCKEDBLOCKED, also persist step3_reason and step3_retry_count. Retry each BLOCKED file once with a focused prompt.CERTAIN, INFERRED, UNCERTAIN)PENDING in on-disk manifest state.The main skill context must not perform bug detection itself. Use the Task tool to spawn dimension-validator agents to detect dimensional bugs in annotated code. For examples, red flags, rationalization checks, and standard vocabulary, see [{baseDir}/references/bug-patterns.md]({baseDir}/references/bug-patterns.md), [{baseDir}/references/common-dimensions.md]({baseDir}/references/common-dimensions.md), and [{baseDir}/references/dimension-algebra.md]({baseDir}/references/dimension-algebra.md). DO NOT DETECT BUGS IN ANY OTHER STEP.
DIMENSIONAL_SCOPE.json.in_scope_files.step4 = "PENDING" for every in-scope file and persist the updated manifest.dimension-validator agent per file. For large repos, run them in waves of roughly 10-30 files to keep orchestration stable.DIMENSIONAL_UNITS.mdDIMENSIONAL_SCOPE.jsonVALIDATED or BLOCKEDVALIDATEDBLOCKEDBLOCKED, also persist step4_reason and step4_retry_count. Retry each BLOCKED file once with a focused prompt.DIM-XXX IDscoverage.unprocessed_files.DIMENSIONAL_SCOPE.json.in_scope_files contains no step4: "PENDING" entries.Pass these references to the relevant subagent when a step needs them:
[{baseDir}/references/dimension-algebra.md]({baseDir}/references/dimension-algebra.md) - Propagator and validator algebra rules[{baseDir}/references/common-dimensions.md]({baseDir}/references/common-dimensions.md) - Validator vocabulary reference[{baseDir}/references/bug-patterns.md]({baseDir}/references/bug-patterns.md) - Validator bug-pattern and red-flag reference[{baseDir}/references/annotate.md]({baseDir}/references/annotate.md) - Annotator format and example referenceAt the end of the analysis, provide a structured summary unless some other output format has been specified:
{
"mode": "full-auto",
"project_root": "<path>",
"vocabulary": {
"base_units": ["..."],
"derived_units": ["..."],
"precision_prefixes": ["..."]
},
"annotations": {
"total_added": 0,
"by_file": {}
},
"findings": {
"critical": 0,
"high": 0,
"medium": 0,
"details": []
},
"uncertainties_resolved": 0,
"coverage": {
"in_scope_files": 0,
"anchor_reviewed_files": "0/0",
"propagation_reviewed_files": "0/0",
"validation_reviewed_files": "0/0",
"annotated_functions": "0/0",
"annotated_variables": "0/0",
"unprocessed_files": [
{
"path": "/path/to/repo/contracts/LegacyMath.sol",
"blocked_step": "step3",
"reason": "Parser could not process generated source",
"retry_count": 1
}
]
}
}
You are NOT done until all of these are true:
DIMENSIONAL_UNITS.md exists in the project rootDIMENSIONAL_SCOPE.json exists in the project root and is the source of truth for downstream coverageDIMENSIONAL_SCOPE.json.in_scope_filesPENDING Step 2 status (ANNOTATED, REVIEWED_NO_ANCHOR_CHANGES, or BLOCKED)PENDING Step 3 status (PROPAGATED, REVIEWED_NO_PROPAGATION_CHANGES, or BLOCKED)PENDING Step 4 status (VALIDATED or BLOCKED)PENDING in any stepBLOCKED file has a documented reason in the final outputcoverage.unprocessed_files exactly matches the final set of terminal BLOCKED files after retries, using path, blocked_step, reason, and retry_countDIMENSIONAL_SCOPE.jsonIf DIMENSIONAL_SCOPE.json and the final report disagree, reconcile the report or continue processing until they match.
Do not claim completion from agent intent alone; completion is determined by manifest coverage and final reported statuses.