audit-full
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseFull-Codebase Audit
全代码库审计
Single-pass whole-project analysis leveraging Opus 4.6's extended context window. Loads entire codebases (~50K LOC) into context for cross-file vulnerability detection, architecture review, and dependency analysis.
借助Opus 4.6的扩展上下文窗口,实现单次全项目分析。将整个代码库(约50K LOC)加载到上下文中,用于跨文件漏洞检测、架构审查和依赖分析。
Quick Start
快速开始
bash
/audit-full # Full audit (all modes)
/audit-full security # Security-focused audit
/audit-full architecture # Architecture review
/audit-full dependencies # Dependency auditOpus 4.6: Usesfor extended thinking across entire codebases. 1M context (beta, Tier 4+) enables cross-file reasoning that chunked approaches miss.complexity: max
bash
/audit-full # 完整审计(所有模式)
/audit-full security # 安全聚焦审计
/audit-full architecture # 架构审查
/audit-full dependencies # 依赖审计Opus 4.6:使用实现跨整个代码库的深度思考。1M上下文(测试版,Tier 4+)支持分块方法无法实现的跨文件推理。complexity: max
STEP 0: Verify User Intent with AskUserQuestion
步骤0:通过AskUserQuestion确认用户意图
BEFORE creating tasks, clarify audit scope:
python
AskUserQuestion(
questions=[
{
"question": "What type of audit do you want to run?",
"header": "Audit mode",
"options": [
{"label": "Full audit (Recommended)", "description": "Security + architecture + dependencies in one pass"},
{"label": "Security audit", "description": "Cross-file vulnerability analysis, data flow tracing, OWASP mapping"},
{"label": "Architecture review", "description": "Pattern consistency, coupling analysis, dependency violations"},
{"label": "Dependency audit", "description": "License compliance, CVE checking, version currency"}
],
"multiSelect": false
},
{
"question": "What should be audited?",
"header": "Scope",
"options": [
{"label": "Entire codebase", "description": "Load all source files into context"},
{"label": "Specific directory", "description": "Focus on a subdirectory (e.g., src/api/)"},
{"label": "Changed files only", "description": "Audit only files changed vs main branch"}
],
"multiSelect": false
}
]
)Based on answers, adjust workflow:
- Full audit: All 3 domains, maximum context usage
- Security only: Focus token budget on source + config files
- Architecture only: Focus on module boundaries, imports, interfaces
- Dependency only: Focus on lock files, manifests, import maps
- Changed files only: Use to scope
git diff --name-only main...HEAD
在创建任务之前,明确审计范围:
python
AskUserQuestion(
questions=[
{
"question": "你想要运行哪种类型的审计?",
"header": "审计模式",
"options": [
{"label": "完整审计(推荐)", "description": "单次扫描完成安全+架构+依赖分析"},
{"label": "安全审计", "description": "跨文件漏洞分析、数据流追踪、OWASP映射"},
{"label": "架构审查", "description": "模式一致性、耦合分析、依赖违规检查"},
{"label": "依赖审计", "description": "许可证合规性、CVE检查、版本时效性"}
],
"multiSelect": false
},
{
"question": "需要审计哪些内容?",
"header": "范围",
"options": [
{"label": "整个代码库", "description": "将所有源文件加载到上下文中"},
{"label": "特定目录", "description": "聚焦子目录(如src/api/)"},
{"label": "仅变更文件", "description": "仅审计与主分支相比有变更的文件"}
],
"multiSelect": false
}
]
)根据回答调整工作流:
- 完整审计:覆盖全部3个领域,最大化利用上下文
- 仅安全审计:将token预算集中在源文件和配置文件上
- 仅架构审计:聚焦模块边界、导入和接口
- 仅依赖审计:聚焦锁文件、清单和导入映射
- 仅变更文件:使用确定范围
git diff --name-only main...HEAD
CRITICAL: Task Management is MANDATORY
重要提示:任务管理是强制性要求
python
TaskCreate(
subject="Full-codebase audit",
description="Single-pass audit using extended context",
activeForm="Running full-codebase audit"
)python
TaskCreate(
subject="全代码库审计",
description="使用扩展上下文的单次审计",
activeForm="正在运行全代码库审计"
)Phase subtasks
阶段子任务
TaskCreate(subject="Estimate token budget and plan loading", activeForm="Estimating token budget")
TaskCreate(subject="Load codebase into context", activeForm="Loading codebase")
TaskCreate(subject="Run audit analysis", activeForm="Analyzing codebase")
TaskCreate(subject="Generate audit report", activeForm="Generating report")
---TaskCreate(subject="估算token预算并规划加载", activeForm="正在估算token预算")
TaskCreate(subject="将代码库加载到上下文", activeForm="正在加载代码库")
TaskCreate(subject="运行审计分析", activeForm="正在分析代码库")
TaskCreate(subject="生成审计报告", activeForm="正在生成报告")
---STEP 1: Estimate Token Budget
步骤1:估算Token预算
Before loading files, estimate whether the codebase fits in context.
在加载文件之前,估算代码库是否能容纳在上下文中。
Run Token Estimation
运行Token估算
bash
undefinedbash
undefinedUse the estimation script
使用估算脚本
bash ${CLAUDE_PLUGIN_ROOT}/src/skills/audit-full/scripts/estimate-tokens.sh /path/to/project
undefinedbash ${CLAUDE_PLUGIN_ROOT}/src/skills/audit-full/scripts/estimate-tokens.sh /path/to/project
undefinedManual Estimation Rules
手动估算规则
| File Type | Tokens per Line (approx) |
|---|---|
| TypeScript/JavaScript | ~8 tokens/line |
| Python | ~7 tokens/line |
| JSON/YAML config | ~5 tokens/line |
| Markdown docs | ~6 tokens/line |
| CSS/SCSS | ~6 tokens/line |
| 文件类型 | 每行Token数(约) |
|---|---|
| TypeScript/JavaScript | ~8 tokens/line |
| Python | ~7 tokens/line |
| JSON/YAML配置 | ~5 tokens/line |
| Markdown文档 | ~6 tokens/line |
| CSS/SCSS | ~6 tokens/line |
Budget Allocation
预算分配
| Context Size | Available for Code | Fits LOC (approx) |
|---|---|---|
| 200K (standard) | ~150K tokens | ~20K LOC |
| 1M (beta) | ~800K tokens | ~100K LOC |
| 上下文大小 | 可用于代码的Token | 可容纳LOC(约) |
|---|---|---|
| 200K(标准) | ~150K tokens | ~20K LOC |
| 1M(测试版) | ~800K tokens | ~100K LOC |
Auto-Exclusion List
自动排除列表
Always exclude from loading:
- ,
node_modules/,vendor/,.venv/__pycache__/ - ,
dist/,build/,.next/out/ - ,
*.min.js,*.map(read lock files separately for deps audit)*.lock - Binary files, images, fonts
- Test fixtures and snapshots (unless auditing tests)
- Generated files (protobuf, graphql codegen)
加载时始终排除以下内容:
- ,
node_modules/,vendor/,.venv/__pycache__/ - ,
dist/,build/,.next/out/ - ,
*.min.js,*.map(依赖审计时单独读取锁文件)*.lock - 二进制文件、图片、字体
- 测试夹具和快照(除非审计测试代码)
- 生成文件(protobuf、graphql代码生成产物)
If Codebase Exceeds Budget
如果代码库超出预算
- Priority loading: Entry points first, then imported modules
- Directory scoping: Ask user to narrow to specific directories
- Fallback: Recommend for chunked multi-agent approach
/ork:verify
python
undefined- 优先加载:先加载入口点,再加载导入模块
- 目录范围限定:请求用户缩小到特定目录
- 备选方案:推荐使用的分块多代理方案
/ork:verify
python
undefinedFallback suggestion
备选方案建议
AskUserQuestion(
questions=[{
"question": "Codebase exceeds context window. How to proceed?",
"header": "Too large",
"options": [
{"label": "Narrow scope", "description": "Audit specific directories only"},
{"label": "Use /ork:verify instead", "description": "Chunked multi-agent approach (works with any context size)"},
{"label": "Priority loading", "description": "Load entry points + critical paths only"}
],
"multiSelect": false
}]
)
---AskUserQuestion(
questions=[{
"question": "代码库超出上下文窗口。如何处理?",
"header": "代码库过大",
"options": [
{"label": "缩小范围", "description": "仅审计特定目录"},
{"label": "改用/ork:verify", "description": "分块多代理方案(适用于任何上下文大小)"},
{"label": "优先加载", "description": "仅加载入口点+关键路径"}
],
"multiSelect": false
}]
)
---STEP 2: Load Codebase into Context
步骤2:将代码库加载到上下文
Loading Strategy
加载策略
- Glob all source files matching inclusion patterns
- Sort by priority: entry points → core modules → utilities → config
- Read files in parallel using multiple Read tool calls per message
- Track loaded tokens to stay within budget
- 匹配包含模式,遍历所有源文件
- 按优先级排序:入口点 → 核心模块 → 工具类 → 配置
- 并行读取文件:每条消息中调用多个Read工具
- 跟踪已加载Token:确保不超出预算
Inclusion Patterns (by language)
各语言的包含模式
bash
undefinedbash
undefinedTypeScript/JavaScript
TypeScript/JavaScript
**/.ts **/.tsx **/.js **/.jsx
**/package.json **/tsconfig.json
**/.ts **/.tsx **/.js **/.jsx
**/package.json **/tsconfig.json
Python
Python
**/*.py
**/pyproject.toml **/setup.cfg */requirements.txt
**/*.py
**/pyproject.toml **/setup.cfg */requirements.txt
Config
配置
**/.env.example /docker-compose.yml **/Dockerfile
**/.yaml **/*.yml (non-lock)
undefined**/.env.example /docker-compose.yml **/Dockerfile
**/.yaml **/*.yml(非锁文件)
undefinedReading Pattern
读取模式
Read files in batches of 10-15 per message for efficiency:
python
undefined为提高效率,按10-15个文件为一批次读取:
python
undefinedBatch 1: Entry points and config
批次1:入口点和配置
Read("src/index.ts")
Read("src/app.ts")
Read("package.json")
Read("tsconfig.json")
Read("src/index.ts")
Read("src/app.ts")
Read("package.json")
Read("tsconfig.json")
... up to 15 files
... 最多15个文件
Batch 2: Core modules
批次2:核心模块
Read("src/api/routes.ts")
Read("src/db/connection.ts")
Read("src/api/routes.ts")
Read("src/db/connection.ts")
... next batch
... 下一批次
---
---STEP 3: Audit Analysis
步骤3:审计分析
With codebase loaded, perform the selected audit mode(s).
代码库加载完成后,执行选定的审计模式。
Security Audit
安全审计
See for the full checklist.
references/security-audit-guide.mdKey cross-file analysis patterns:
- Data flow tracing: Track user input from entry point → processing → storage
- Auth boundary verification: Ensure all protected routes check auth
- Secret detection: Scan for hardcoded credentials, API keys, tokens
- Injection surfaces: SQL, command, template injection across file boundaries
- OWASP Top 10 mapping: Classify findings by OWASP category
完整检查清单请参考。
references/security-audit-guide.md关键跨文件分析模式:
- 数据流追踪:跟踪用户输入从入口点→处理→存储的全流程
- 认证边界验证:确保所有受保护路由都检查认证
- 密钥检测:扫描硬编码凭证、API密钥和令牌
- 注入面检查:跨文件边界的SQL、命令、模板注入
- OWASP Top 10映射:按OWASP类别分类发现的问题
Architecture Review
架构审查
See for the full guide.
references/architecture-review-guide.mdKey analysis patterns:
- Dependency direction: Verify imports flow inward (clean architecture)
- Circular dependencies: Detect import cycles across modules
- Layer violations: Business logic in controllers, DB in routes, etc.
- Pattern consistency: Same problem solved differently across codebase
- Coupling analysis: Count cross-module imports, identify tight coupling
完整指南请参考。
references/architecture-review-guide.md关键分析模式:
- 依赖方向:验证导入是否符合向内流动(整洁架构)
- 循环依赖:检测跨模块的导入循环
- 层级违规:控制器中包含业务逻辑、路由中包含数据库操作等
- 模式一致性:代码库中同一问题的解决方式不一致
- 耦合分析:统计跨模块导入次数,识别强耦合
Dependency Audit
依赖审计
See for the full guide.
references/dependency-audit-guide.mdKey analysis patterns:
- Known CVEs: Check versions against known vulnerabilities
- License compliance: Identify copyleft licenses in proprietary code
- Version currency: Flag significantly outdated dependencies
- Transitive risk: Identify deep dependency chains
- Unused dependencies: Detect installed but never imported packages
完整指南请参考。
references/dependency-audit-guide.md关键分析模式:
- 已知CVE:检查版本是否存在已知漏洞
- 许可证合规性:识别专有代码中的 copyleft 许可证
- 版本时效性:标记严重过时的依赖
- 传递风险:识别深层依赖链
- 未使用依赖:检测已安装但从未导入的包
STEP 4: Generate Report
步骤4:生成报告
Use the report template from .
assets/audit-report-template.md使用中的报告模板。
assets/audit-report-template.mdReport Structure
报告结构
markdown
undefinedmarkdown
undefinedAudit Report: {project-name}
审计报告:{项目名称}
Date: {date} | Mode: {mode} | Files loaded: {count} | LOC: {loc}
日期: {日期} | 模式: {模式} | 已加载文件数: {数量} | LOC: {行数}
Executive Summary
执行摘要
{1-3 sentences: overall health, critical findings count}
{1-3句话:整体健康状况、关键问题数量}
Findings
发现的问题
| # | Severity | Category | File(s) | Finding | Remediation |
|---|---|---|---|---|---|
| 1 | CRITICAL | Security | src/auth.ts:42 | ... | ... |
| # | 严重程度 | 类别 | 文件 | 问题描述 | 修复建议 |
|---|---|---|---|---|---|
| 1 | 关键 | 安全 | src/auth.ts:42 | ... | ... |
Severity Breakdown
严重程度分布
- CRITICAL: {n} (must fix before deploy)
- HIGH: {n} (fix within sprint)
- MEDIUM: {n} (fix within quarter)
- LOW: {n} (track and address)
- 关键:{n}(部署前必须修复)
- 高:{n}(迭代内修复)
- 中:{n}(季度内修复)
- 低:{n}(跟踪并处理)
Architecture Diagram
架构图
{ASCII diagram of module dependencies}
{模块依赖的ASCII图}
Recommendations
建议
{Prioritized action items}
undefined{按优先级排序的行动项}
undefinedSeverity Classification
严重程度分类
See for classification criteria.
assets/severity-matrix.md分类标准请参考。
assets/severity-matrix.mdCompletion Checklist
完成检查清单
Before finalizing the report, verify with .
checklists/audit-completion.md最终确定报告前,请使用进行验证。
checklists/audit-completion.mdWhen NOT to Use
不适用场景
| Situation | Use Instead |
|---|---|
| Small targeted check (1-5 files) | Direct Read + analysis |
| CI/CD automated scanning | |
| Multi-agent graded verification | |
| Exploring unfamiliar codebase | |
| Context window < 200K tokens | |
| 场景 | 替代方案 |
|---|---|
| 小型针对性检查(1-5个文件) | 直接读取+分析 |
| CI/CD自动化扫描 | |
| 多代理分级验证 | |
| 探索不熟悉的代码库 | |
| 上下文窗口<200K tokens | |
Related Skills
相关技能
- — Automated scanner integration (npm audit, Semgrep, etc.)
security-scanning - — 8-layer security architecture patterns
defense-in-depth - — OWASP vulnerability classification
owasp-top-10 - — Architectural pattern reference
clean-architecture - — Quality assessment criteria
quality-gates - — Chunked multi-agent verification (fallback for large codebases)
verify
- — 自动化扫描器集成(npm audit、Semgrep等)
security-scanning - — 8层安全架构模式
defense-in-depth - — OWASP漏洞分类
owasp-top-10 - — 架构模式参考
clean-architecture - — 质量评估标准
quality-gates - — 分块多代理验证(大型代码库的备选方案)
verify
References
参考资料
- Security Audit Guide — Cross-file vulnerability patterns
- Architecture Review Guide — Pattern and coupling analysis
- Dependency Audit Guide — CVE, license, currency checks
- Token Estimation — File type ratios and budget planning
- Audit Report Template — Structured output format
- Severity Matrix — Finding classification criteria
- Audit Completion Checklist — Pre-report verification
- Token Estimation Script — Automated LOC → token estimation
- 安全审计指南 — 跨文件漏洞模式
- 架构审查指南 — 模式和耦合分析
- 依赖审计指南 — CVE、许可证、时效性检查
- Token估算 — 文件类型比例和预算规划
- 审计报告模板 — 结构化输出格式
- 严重程度矩阵 — 问题分类标准
- 审计完成检查清单 — 报告前验证
- Token估算脚本 — 自动化LOC→Token估算