数据分析
- 作者仓库星标 5,723
- 叉子 499
- 作者更新于 2026年6月15日 16:05
- 作者仓库 skills
- 领域
- 通用
- 兼容 Agent
-
- Claude Code
- Cursor
- Cline
- Codex
- Windsurf
- Gemini CLI
- +20
- 信任分
- 88 / 100 · 社区维护
- 作者 / 版本 / 许可
- @trailofbits · 未声明 license
- Token 消耗评级
- 较高消耗
- 接入复杂程度
- 需简单配置
- 是否需要外部 API Key
- 不需要
- 兼容的系统
- 未声明(默认跨平台)
- 底层运行要求
- 无特殊要求
- 文件与系统权限
-
- 只读
- 允许写入 / 修改
- Shell 执行
- 网络行为
- 仅限本地
- 安装命令数
- 26 条
档案由构建时根据 SKILL.md 与安装命令自动衍生,可能与作者实际意图存在差异。
需要注意: 未限定 allowed-tools,默认拥有全部工具权限。
---
name: dimensional-analysis
description: Annotates codebases with dimensional analysis comments documenting units, dimensions, and decima…
category: 通用
runtime: 无特殊运行时
---
# dimensional-analysis 输出预览
## PART A: 任务判断
- 适用问题:通用任务拆解、检查和交付。
- 输入要求:目标材料、限制条件、期望输出和验收方式。
- 证据边界:围绕“When to Use / When NOT to Use / Execution Mode”读取原文规则,不把推断写成作者承诺。
## PART B: 执行结果
- **01** 任务判断:确认你的需求是否属于通用任务拆解、检查和交付,并标出输入、限制和预期结果。
- **02** 执行计划:优先按“When to Use / When NOT to Use / Execution Mode”拆成步骤,说明每一步会读取什么、修改什么、产出什么。
- **03** 交付结果:给出可复制的命令、文件改动、检查清单或内容草稿,并说明如何继续迭代。
- **04** 风险边界:结合 读取文件、写入/修改文件、执行终端命令、主要在本地完成、通常不需要额外 API Key 给出执行前确认项。
## Running Rules
- 读取文件、写入/修改文件、执行终端命令;主要在本地完成;通常不需要额外 API Key。
- 先小样例验证,再放大到真实任务。
- 交付时同时给结果、检查口径和下一步迭代建议。 原文没有稳定的斜杠命令要求。安装验证后通常全局生效,直接在对话里点名这个 Skill 并描述任务即可。
告诉 Agent 目标文件或材料、期望结果、不可改范围、是否允许联网或执行命令。本 Skill 的权限画像是:读取文件、写入/修改文件、执行终端命令。
先用一个小任务确认它会围绕“When to Use / When NOT to Use / Execution Mode”工作;涉及文件或命令时,先看 diff、日志、预览或测试结果。
检查最终产物是否包含明确结果、必要证据和下一步动作;如果输出泛泛而谈,就补充输入、边界和验收标准后重跑。
---
name: dimensional-analysis
description: Annotates codebases with dimensional analysis comments documenting units, dimensions, and decima…
category: 通用
source: trailofbits/skills
---
# dimensional-analysis
## 什么时候使用
- dimensional-analysis 是一个通用扩展技能,按 SKILL 适合处理通用任务拆解、检查、交付和复盘,核心价值是把输入、判断、执行、验证和交付边界固定下来,避免 Agent 泛泛回答。 把任务拆成可执行、可检查、可继续迭…
- 面向通用任务拆解、检查和交付,优先处理能明确输入、步骤和验收标准的工作。
## 需要提供什么
- 目标材料、目录范围、期望结果和不可改动内容。
- 是否允许联网、执行命令、读写文件或调用外部服务。
## 执行规则
- 围绕「When to Use / When NOT to Use / Execution Mode」组织步骤,不把推断写成作者事实。
- 读取文件、写入/修改文件、执行终端命令;主要在本地完成;通常不需要额外 API Key。
- 先跑小样例,确认结果可检查后再扩大任务范围。
## 输出要求
- 给出最终产物、关键证据、验证方式和下一步动作。
- 信息不足时标记 unknown,不编造命令、平台或依赖。 作者原文负责流程事实;仓库文件负责来源和命令;流狐只补充适用场景、限制和质量判断。
skill "dimensional-analysis" {
输入层 -> 用户目标 + 目标文件 + 禁止范围 + 验收标准
上下文层 -> When to Use / When NOT to Use / Execution Mode
规则层 -> SKILL.md 触发条件 / 执行顺序 / 输出格式
运行层 -> 无特殊运行时 | 读取文件、写入/修改文件、执行终端命令 | 主要在本地完成
安全层 -> 通常不需要额外 API Key + 小任务验证 + diff / 日志复核
输出层 -> 可复制结果 + 检查清单 + 下一步迭代
} Dimensional Analysis Skill
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.
When to Use
- Annotating a codebase with unit/dimension comments (e.g.,
D18{tok},D27{UoA/tok}) - Performing dimensional analysis on DeFi protocols, financial code, or scientific computations
- Hunting for arithmetic bugs caused by unit mismatches, missing scaling, or precision loss
- Auditing codebases with mixed decimal precisions or fixed-point arithmetic
When NOT to Use
- Codebases with no numeric arithmetic or unit conversions — there is nothing to annotate
- Pure integer counting logic (loop indices, array lengths) with no physical or financial dimensions
- When you only need a quick spot-check of a single formula — read the code directly instead of running the full pipeline
Execution Mode
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.
- Always run the full pipeline in this order: Step 1 -> Step 2 -> Step 3 -> Step 4.
- The main skill context must not perform repository-wide dimensional analysis, annotation, propagation, or bug validation itself when a dedicated subagent exists for that step.
- The main skill context may inspect artifacts, manifests, and subagent outputs only as needed to route work, build prompts, persist state, and determine completion.
- Any mode argument provided by the caller is ignored.
- Report all results at the end in a single summary.
When you start a step, report it:
Starting Step: Step {n}
Scope and Coverage Guarantees
This skill must audit all in-scope arithmetic files, including large repositories.
- In-scope files are defined by Step 1 scanner output (
filesarray), across all priority tiers (CRITICAL, HIGH, MEDIUM, LOW). - If Step 1 narrows inputs for vocabulary discovery (for example, CRITICAL/HIGH only), that narrowing applies to discovery only. It never reduces annotation or validation scope.
arithmetic-scannerpersists the in-scope file manifest toDIMENSIONAL_SCOPE.jsonin the project root, and that manifest is the source of truth for Steps 2-4.- A file is considered fully covered only when all three statuses are present:
step2: anchor annotation completed (or explicit no-anchor result)step3: propagation completed (or explicit no-propagation result)step4: validation completed
dimension-discovererpersists the discovered dimensional vocabulary toDIMENSIONAL_UNITS.mdin the project root for reuse by later steps and future runs.- When a file ends in a terminal
BLOCKEDstate, persist the blocking reason and retry count inDIMENSIONAL_SCOPE.jsonand reflect the same file incoverage.unprocessed_files. - Do not finish while any in-scope file remains unprocessed in any step.
Delegation Contract
arithmetic-scannerowns repository scanning, arithmetic-file prioritization, and writingDIMENSIONAL_SCOPE.json.dimension-discovererowns dimensional vocabulary discovery, unit inference, and writingDIMENSIONAL_UNITS.md.dimension-annotatorowns annotation format decisions, anchor-point edits, and comment-writing behavior.dimension-propagatorowns propagation logic, inferred annotations, and mismatch reporting during tracing.dimension-validatorowns bug detection, red-flag evaluation, rationalization rejection, and confirmation or refutation of propagated mismatches.- The main skill context must not substitute its own dimensional reasoning for skipped or unlaunched subagents. If a step requires specialized reasoning, launch the corresponding subagent.
- Use reference files as subagent support material. Pass them to the relevant step in prompts instead of treating them as instructions for the main skill context.
Workflow
Follow these sections in order. Do not advance until the current step satisfies its completion gate.
Shared Orchestration Rules
DIMENSIONAL_SCOPE.jsonandDIMENSIONAL_UNITS.mdlive in the project root.- The main skill context verifies Step 1 artifacts but does not write either Step 1 artifact itself.
DIMENSIONAL_SCOPE.json.in_scope_filesis the source of truth for Steps 2-4. Never derive later scope from discovery-only inputs.- When a later step reaches terminal
BLOCKED, persist the matchingstep*_reasonandstep*_retry_countfields on the file entry inDIMENSIONAL_SCOPE.json. coverage.unprocessed_filesmust be derived from terminalBLOCKEDentries inDIMENSIONAL_SCOPE.jsonusing{ "path": "...", "blocked_step": "step2|step3|step4", "reason": "...", "retry_count": 1 }.- A step may retry a
BLOCKEDfile once with a focused prompt. If it is stillBLOCKED, keep the documented reason and continue. Do not finalize while any file remainsPENDING.
Step 1: Vocabulary and Scope Discovery
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.
- Check whether
DIMENSIONAL_UNITS.mdandDIMENSIONAL_SCOPE.jsonalready exist in the project root. - If both exist, read them and confirm:
DIMENSIONAL_SCOPE.json.project_rootmatches the current repo rootDIMENSIONAL_SCOPE.jsoncontainsin_scope_files,discoverer_focus_files,recommended_discovery_order, and per-filestep2,step3,step4fieldsDIMENSIONAL_UNITS.mdis a usable dimensional vocabulary for this repo
- If either artifact is stale, malformed, missing required structure, or clearly for another repo, discard reuse and rerun the rest of Step 1.
- If both artifacts are valid, reuse them directly. If
in_scope_filesis empty, skip Steps 2-4 and produce final output with zero findings. - Otherwise use the
Tasktool to spawn thearithmetic-scanneragent. Its prompt must include:- project root path
- absolute output path for
DIMENSIONAL_SCOPE.json - instruction to write the Step 1 scope manifest to disk and return the same scope data in its report
- The scanner owns Step 1 scope persistence. It must:
- identify dimensional-arithmetic files and prioritize them as usual
- write
DIMENSIONAL_SCOPE.jsonwithproject_root,in_scope_files,discoverer_focus_files, andrecommended_discovery_order - initialize every in-scope file with
step2: "PENDING",step3: "PENDING", andstep4: "PENDING" - still write an empty manifest when no arithmetic files are found
- still narrow
discoverer_focus_filesto CRITICAL/HIGH when more than 50 arithmetic files are found, while keeping all priorities inin_scope_files
- After the scanner completes, read
DIMENSIONAL_SCOPE.jsonfrom disk and confirm it exists and contains the required Step 1 fields before continuing. - Use the
Tasktool to spawn thedimension-discovereragent. Its prompt must include:- project root path
- absolute path to
DIMENSIONAL_SCOPE.json - absolute output path for
DIMENSIONAL_UNITS.md - prioritized
discoverer_focus_fileswith each file's path, priority, score, and category recommended_discovery_order
- The discoverer owns Step 1 vocabulary persistence. It must read
DIMENSIONAL_SCOPE.jsonas the Step 1 source of truth and writeDIMENSIONAL_UNITS.mdwithBase Units,Derived Units, andPrecision Prefixessections. Ifin_scope_filesis empty, it must still write the same headings with empty sections. - Step 1 is complete only when both artifacts exist on disk, pass the reuse checks above, and correctly represent the zero-file case. If
in_scope_filesis empty after the discoverer writesDIMENSIONAL_UNITS.md, skip Steps 2-4 and produce final output with zero findings.
Step 2: Anchor Annotation
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).
- Read
DIMENSIONAL_SCOPE.jsonand build batches fromin_scope_files. Every in-scope file, including MEDIUM and LOW priority files, must receive a Step 2 outcome. - Batch files instead of spawning one agent per file:
<= 10files: one batch11-30files: one batch per category> 30files: one batch per category, splitting categories larger than 10 files into sub-batches of about 8 files
- Launch categories in Step 1 recommended discovery order: math libraries, then oracles, then core logic, then peripheral. Batches inside the same category may run in parallel.
- Before launching annotators, set
step2 = "PENDING"for every in-scope file and persist the updatedDIMENSIONAL_SCOPE.json. - Each annotator prompt must include:
- absolute path to
DIMENSIONAL_UNITS.md - absolute path to
DIMENSIONAL_SCOPE.json - assigned file paths in order
- each file's category and matched patterns from scanner output
- summary of previously annotated interfaces or types from earlier batches, when applicable
- required per-file status output:
ANNOTATED,REVIEWED_NO_ANCHOR_CHANGES, orBLOCKEDplus a one-line justification
- absolute path to
- After each batch, immediately persist each assigned file to exactly one Step 2 status:
ANNOTATEDREVIEWED_NO_ANCHOR_CHANGESBLOCKED
- If a file is
BLOCKED, also persiststep2_reasonandstep2_retry_count. Retry eachBLOCKEDfile once with a focused prompt. - Do not continue to Step 3 while any file remains
PENDINGin on-disk manifest state.
Step 3: Dimension Propagation
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).
- Read
DIMENSIONAL_SCOPE.jsonand build propagation batches fromin_scope_files. Every in-scope file must receive a Step 3 outcome. - Use the same batching rules and category ordering as Step 2.
- Before launching propagators, confirm every file already has a non-pending Step 2 status.
- Then set
step3 = "PENDING"for every in-scope file and persist the updated manifest. - Each propagator prompt must include:
- absolute path to
DIMENSIONAL_UNITS.md - absolute path to
DIMENSIONAL_SCOPE.json - assigned file paths in order
- each file's category and matched patterns
- summary of Step 2 anchor annotations for the assigned files and any upstream interfaces they depend on
- required per-file status output:
PROPAGATED,REVIEWED_NO_PROPAGATION_CHANGES, orBLOCKEDplus a one-line justification
- absolute path to
- After each batch, immediately persist each assigned file to exactly one Step 3 status:
PROPAGATEDREVIEWED_NO_PROPAGATION_CHANGESBLOCKED
- If a file is
BLOCKED, also persiststep3_reasonandstep3_retry_count. Retry eachBLOCKEDfile once with a focused prompt. - After all propagators complete, aggregate:
- annotations added by confidence level (
CERTAIN,INFERRED,UNCERTAIN) - mismatches found, with severities for validator deduplication
- coverage gaps that could not be inferred
- annotations added by confidence level (
- Do not continue to Step 4 while any file remains
PENDINGin on-disk manifest state.
Step 4: Bug Detection
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.
- Validate every file in
DIMENSIONAL_SCOPE.json.in_scope_files. - Use this priority order without skipping lower tiers:
- files with CRITICAL or HIGH Step 3 mismatches
- remaining CRITICAL and HIGH scanner-priority files
- remaining MEDIUM and LOW files
- Before launching validators, confirm every file already has a non-pending Step 3 status.
- Then set
step4 = "PENDING"for every in-scope file and persist the updated manifest. - Spawn one
dimension-validatoragent per file. For large repos, run them in waves of roughly 10-30 files to keep orchestration stable. - Each validator prompt must include:
- absolute path to
DIMENSIONAL_UNITS.md - absolute path to
DIMENSIONAL_SCOPE.json - the single file path to validate
- a summary of anchor and propagated annotations in the file
- Step 3 mismatch summaries for the file, including mismatch IDs
- cross-file function signatures or return dimensions needed for call-boundary checks
- required per-file status output:
VALIDATEDorBLOCKED
- absolute path to
- After each wave, immediately persist each file to exactly one Step 4 status:
VALIDATEDBLOCKED
- If a file is
BLOCKED, also persiststep4_reasonandstep4_retry_count. Retry eachBLOCKEDfile once with a focused prompt. - Deduplicate findings:
- confirmed Step 3 mismatches keep their original IDs and severities
- refuted Step 3 mismatches are noted as false positives and excluded from final counts
- genuinely new findings receive new
DIM-XXXIDs
- Aggregate confirmed findings, new findings, refuted findings, coverage summary, and final
coverage.unprocessed_files. - Step 4 is complete only when
DIMENSIONAL_SCOPE.json.in_scope_filescontains nostep4: "PENDING"entries.
Reference Documentation
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 reference
Final Output
At 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
}
]
}
}
Completion Checklist
You are NOT done until all of these are true:
File Coverage Gates
-
DIMENSIONAL_UNITS.mdexists in the project root -
DIMENSIONAL_SCOPE.jsonexists in the project root and is the source of truth for downstream coverage - Every in-scope arithmetic file discovered in Step 1 appears in
DIMENSIONAL_SCOPE.json.in_scope_files - Every in-scope file has a non-
PENDINGStep 2 status (ANNOTATED,REVIEWED_NO_ANCHOR_CHANGES, orBLOCKED) - Every in-scope file has a non-
PENDINGStep 3 status (PROPAGATED,REVIEWED_NO_PROPAGATION_CHANGES, orBLOCKED) - Every in-scope file has a non-
PENDINGStep 4 status (VALIDATEDorBLOCKED) - No in-scope file remains
PENDINGin any step - Any
BLOCKEDfile has a documented reason in the final output -
coverage.unprocessed_filesexactly matches the final set of terminalBLOCKEDfiles after retries, usingpath,blocked_step,reason, andretry_count
Summary Report
- Final summary JSON/report provided
- Final coverage counters match
DIMENSIONAL_SCOPE.json - List of modified files provided when edits occurred
- Any dimensional mismatches or bugs found are summarized
- Any remaining blocked or unprocessed files are called out with reasons
If 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.
先判断是否适合
作者设计意图
作者的方法与取舍
边界和复核