accelint-ts-audit-all
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAudit All
全量审计
Comprehensive TypeScript file audit system that systematically applies multiple audit skills with progress tracking and interactive approval.
全面的TypeScript文件审计系统,可系统化应用多个审计Skill,支持进度追踪和交互式审批。
NEVER Do When Running Audits
审计运行禁忌事项
- NEVER skip the initial test coverage step - Refactoring without test coverage first leads to undetected breakage. Always run before any code changes.
accelint-ts-testing - NEVER run best-practices and performance sequentially - Running them separately creates contradictory recommendations for the same code. Always run in parallel to see merged suggestions.
- NEVER present issues one-by-one for approval - Always show ALL issues in a numbered table first, then display each issue's detailed before/after code, THEN ask for numbered list acceptance. This prevents wildly inconsistent presentations and allows users to spot conflicts across parallel processes.
- NEVER skip displaying the overview table - BLOCKING: You MUST display the emoji severity table with ALL issues before showing any detailed changes. No exceptions.
- NEVER ask for approval before showing all detailed changes - BLOCKING: You MUST show the complete before/after code for EVERY issue before asking "Apply which issues?"
- NEVER auto-apply all recommendations - Each change needs user approval (accept/deny/other) to maintain code ownership and prevent unwanted modifications.
- NEVER run one-off commands instead of documented verification commands - The audit-process file documents EXACT verification commands. Use those commands verbatim. Never improvise with ,
npm test, or similar unless they match the documented commands exactly.bun test - NEVER skip saving progress after completing a step - After EVERY step completion, immediately save detailed progress to audit-process file BEFORE moving to next step. Context limits will break otherwise.
- NEVER skip the 100-pass PBT verification - When property-based tests are added, you MUST run the test suite 100 times to verify stability. Random failures are common with PBT. This is a blocking requirement - do not proceed until 100 consecutive passes are achieved. Run the tests without coverage reporting on to increase speed and stability.
- NEVER lose progress when context runs out - Save detailed progress to audit-process file after each step. Context limits are guaranteed in large audits.
- NEVER assume property-based tests are stable - Random test failures are common with PBT. Run new property tests 100 times to verify stability before accepting. Run the tests without coverage reporting on to increase speed and stability.
- NEVER add PERF comments everywhere - Only add comments when they provide meaningful insight that future developers wouldn't discover on their own.
// PERF: - NEVER mark a file complete without all 9 steps - Partial audits leave files in inconsistent states. Complete all steps or mark as in-progress.
- NEVER move on from a broken build - Fix compilation errors, test failures, and lint issues immediately before proceeding to the next step.
- NEVER run audit in main branch - Always create an isolated worktree to prevent conflicts with parallel audits and allow safe experimentation.
- 绝对不要跳过初始测试覆盖率步骤 - 没有测试覆盖就重构会导致无法发现的功能损坏。任何代码变更前务必先运行。
accelint-ts-testing - 绝对不要顺序运行最佳实践和性能审计 - 分开运行会对同一段代码产生互相矛盾的建议,务必并行运行以查看合并后的优化建议。
- 绝对不要逐个展示问题要求审批 - 务必先以编号表格形式展示所有问题,再展示每个问题的代码变更前后对比,最后要求用户通过编号列表选择要接受的变更。避免展示格式混乱,也方便用户发现并行流程产生的冲突。
- 绝对不要跳过概览表格展示 - 强制要求:展示任何详细变更前,你必须先展示包含所有问题的表情符号严重等级表格,无任何例外。
- 绝对不要在展示所有详细变更前要求审批 - 强制要求:询问“要应用哪些问题的修复?”之前,你必须展示每个问题完整的代码变更前后对比。
- 绝对不要自动应用所有建议 - 每个变更都需要用户审批(接受/拒绝/其他操作),保障代码所有权,避免非预期修改。
- 绝对不要运行临时命令替代文档规定的校验命令 - 审计流程文档中明确记录了校验命令,必须原样使用。除非完全匹配文档记录的命令,否则不要自行使用、
npm test等类似命令。bun test - 绝对不要在完成步骤后跳过进度保存 - 每完成一个步骤,进入下一个步骤前必须立即将详细进度保存到审计流程文件中,否则上下文限制会导致进度丢失。
- 绝对不要跳过100次PBT校验运行 - 新增基于属性的测试(PBT)后,必须运行测试套件100次验证稳定性,PBT经常会出现随机失败。这是强制要求,必须连续100次运行通过才能继续。运行测试时关闭覆盖率上报以提升速度和稳定性。
- 绝对不要在上下文耗尽时丢失进度 - 每个步骤完成后都要将详细进度保存到审计流程文件中,大型审计必然会遇到上下文限制问题。
- 绝对不要假设PBT是稳定的 - PBT经常出现随机测试失败,接受新增的属性测试前必须运行100次验证稳定性。运行测试时关闭覆盖率上报以提升速度和稳定性。
- 绝对不要随处添加PERF注释 - 只有当注释能为后续开发者提供无法自行发现的有价值见解时,才添加注释。
// PERF: - 绝对不要在未完成全部9个步骤时标记文件已完成 - 部分审计会导致文件处于不一致状态,要么完成所有步骤,要么标记为进行中。
- 绝对不要在构建失败时继续流程 - 进入下一个步骤前必须立即修复编译错误、测试失败和lint问题。
- 绝对不要在main分支运行审计 - 始终创建隔离的worktree,避免与并行审计产生冲突,也可以安全地进行试验。
Before Starting an Audit, Ask
启动审计前的确认项
Apply these tests before launching a comprehensive audit:
启动全量审计前完成以下检查:
Scope Validation
范围校验
- Is this path valid and accessible? Verify the file or directory exists before creating TODO lists.
- Are there test and build commands available? Check package.json or ask user for verification commands before starting.
- How many files will this audit? Large directories (>5 files) will require multiple sessions. Set expectations upfront.
- 路径是否有效可访问? 创建TODO列表前验证文件或目录是否存在。
- 是否有可用的测试和构建命令? 启动前检查package.json或询问用户获取校验命令。
- 本次审计涉及多少个文件? 大型目录(超过5个文件)需要多会话完成,提前和用户同步预期。
Session Management
会话管理
- Is this a new audit or resuming? Check for existing audit-process files in before creating new ones.
.agents/audit/ - Will this fit in one session? Estimate ~1-5 files per session max. Plan for resumption if larger.
- Are verification commands known? Document exact test/build/lint commands in the audit-process file from the start.
- 是新审计还是恢复已有的审计? 创建新的审计流程文件前检查目录下是否已有审计流程文件。
.agents/audit/ - 本次审计是否能在单个会话内完成? 预估每个会话最多处理1~5个文件,如果审计规模更大则提前规划恢复机制。
- 是否明确校验命令? 从一开始就将准确的测试/构建/lint命令记录到审计流程文件中。
Change Philosophy
变更原则
- What's the user's risk tolerance? Some users want every suggestion, others only critical fixes. Clarify before first interactive prompt.
- Should performance micro-optimizations be included? 1.05x-1.15x gains may not be worth code churn for all projects.
- 用户的风险承受能力是多少? 部分用户希望采纳所有建议,部分用户只需要修复严重问题,在第一次交互式提示前确认清楚。
- 是否要包含性能微优化? 1.05x-1.15x的性能提升对部分项目来说不值得产生代码变更,需要提前确认。
How to Use
使用方法
This skill creates and maintains an audit process file that tracks progress across sessions. It systematically runs four audit skills on each file with interactive approval.
本Skill会创建并维护审计流程文件,实现跨会话进度追踪,会对每个文件系统化运行4个审计Skill,并支持交互式审批。
Workflow Overview
工作流概览
- Initialize - Create TODO list and audit tracking files
- For each file - Run 9-step audit process with user approval
- Track progress - Save after each step to survive context limits
- Archive completed - Move finished files to history file
- 初始化 - 创建TODO列表和审计追踪文件
- 遍历每个文件 - 运行9步审计流程,搭配用户审批
- 追踪进度 - 每个步骤完成后保存,避免上下文限制导致进度丢失
- 归档已完成文件 - 将处理完成的文件移动到历史文件
Main Audit Workflow
核心审计工作流
Step 1: Initialize the Audit
步骤1:初始化审计
Check for existing audit: Look in directory (in the original repository root) for existing audit-process files.
.agents/audit/Note: Ensure is in your project's to prevent committing audit tracking files.
.agents/audit/.gitignoreIf resuming an existing audit, read the audit-process file to understand current status:
-
Check completion status:
- Review "Current Status" section for files completed vs remaining
- Review "Files to Audit" section for pending/completed breakdown
- If all files are marked "Completed", the audit is done
-
Check worktree status (backwards compatibility):
- If "Worktree Information" section exists: verify worktree still exists and switch to it
- If no worktree documented: this is a legacy audit from before worktree support. Continue in current branch without creating a worktree.
- Note: Only NEW audits created after this feature will use worktrees
-
Continue from "Resume Instructions" section
Skip to Step 2 if resuming.
For new audits, create isolated worktree:
BLOCKING: All audit work MUST happen in an isolated worktree to prevent conflicts with parallel audits and allow safe rollback.
-
Create worktree with timestamped branch:bash
timestamp=$(date +%Y%m%d-%H%M%S) git worktree add .agents/worktrees/audit-${timestamp} -b audit/${timestamp} -
Switch to the worktree directory:bash
cd .agents/worktrees/audit-${timestamp} -
Log the worktree path - You will work in this directory for the entire audit
Important: The worktree is created in (not ) to avoid conflicts with the gitignored directory where tracking files are stored.
.agents/worktrees/.agents/audit/.agents/audit/Create tracking files:
MANDATORY - READ ENTIRE FILE: Before creating any tracking files, you MUST read
completely
from start to finish to understand the exact format and structure required.
NEVER set any range limits when reading this file.
assets/audit-process-template.mdSimilarly, you MUST read
to understand the archival format.
assets/audit-history-template.mdDo NOT load these templates again after the initial setup - they are only needed
once at the start of a new audit.
Create timestamped tracking files in the ORIGINAL repository (not in the worktree):
- Go back to the original repository root:
cd $(git rev-parse --show-toplevel) - Create (use same timestamp as worktree)
.agents/audit/audit-process-${timestamp}.md - Create (same timestamp)
.agents/audit/audit-history-${timestamp}.md - Return to the worktree:
cd .agents/worktrees/audit-${timestamp}
Important: Tracking files live in the original repo's directory (which should be gitignored) so they are NOT committed with audit changes.
.agents/audit/Build the TODO list:
Find all TypeScript files in the target directory, excluding , , and files. If given a single file, validate it's not a test/benchmark file.
.test.ts.spec.ts.bench.tsPopulate the audit-process file:
- Add worktree path and branch to "Worktree Information" section
- Add all files to "Files to Audit" section as "Pending"
- Document the exact verification commands (test/build/lint)
- Set "Current File" to first pending file
- Save the file
检查已有审计: 查看(原仓库根目录下的)目录是否存在已有审计流程文件。
.agents/audit/注意: 确保已加入项目的,避免提交审计追踪文件。
.agents/audit/.gitignore如果是恢复已有审计,读取审计流程文件了解当前状态:
-
检查完成状态:
- 查看「当前状态」部分,确认已完成和待处理的文件
- 查看「待审计文件」部分,确认待处理/已完成的拆分
- 如果所有文件都标记为「已完成」,则审计结束
-
检查worktree状态(向后兼容):
- 如果存在「Worktree信息」部分:验证worktree仍然存在并切换到对应目录
- 如果没有记录worktree:这是worktree功能上线前的遗留审计,在当前分支继续即可,无需创建新的worktree
- 注意:只有本功能上线后创建的新审计才会使用worktree
-
从「恢复指引」部分继续流程
如果是恢复审计,直接跳转到步骤2。
新审计需要创建隔离worktree:
强制要求:所有审计工作必须在隔离的worktree中开展,避免与并行审计产生冲突,也支持安全回滚。
-
创建带时间戳分支的worktree:bash
timestamp=$(date +%Y%m%d-%H%M%S) git worktree add .agents/worktrees/audit-${timestamp} -b audit/${timestamp} -
切换到worktree目录:bash
cd .agents/worktrees/audit-${timestamp} -
记录worktree路径 - 整个审计过程都将在该目录下开展
重要提示: worktree创建在目录(而非目录),避免和git忽略的追踪文件目录产生冲突。
.agents/worktrees/.agents/audit/.agents/audit/创建追踪文件:
强制要求 - 完整阅读文件: 创建任何追踪文件前,你必须完整通读的全部内容,了解要求的准确格式和结构,读取该文件时绝对不要设置任何范围限制。
assets/audit-process-template.md同样,你必须通读了解归档格式。
assets/audit-history-template.md初始设置完成后不要再加载这些模板,仅在新审计启动时读取一次即可。
在原仓库(而非worktree中)创建带时间戳的追踪文件:
- 回到原仓库根目录:
cd $(git rev-parse --show-toplevel) - 创建(使用和worktree相同的时间戳)
.agents/audit/audit-process-${timestamp}.md - 创建(相同时间戳)
.agents/audit/audit-history-${timestamp}.md - 回到worktree:
cd .agents/worktrees/audit-${timestamp}
重要提示: 追踪文件存放在原仓库的目录(该目录应该被git忽略),不会随审计变更一起提交。
.agents/audit/构建TODO列表:
查找目标目录下的所有TypeScript文件,排除、和文件。如果指定的是单个文件,验证它不是测试/基准测试文件。
.test.ts.spec.ts.bench.ts填充审计流程文件:
- 在「Worktree信息」部分添加worktree路径和分支
- 将所有文件添加到「待审计文件」部分,标记为「待处理」
- 记录准确的校验命令(测试/构建/lint)
- 将「当前文件」设置为第一个待处理文件
- 保存文件
Step 2: Audit Each File (8-Step Process)
步骤2:审计每个文件(8步流程)
For each file in the pending list, follow this exact sequence:
对待处理列表中的每个文件,严格遵循以下顺序执行:
Phase 1: Initial Test Coverage
阶段1:初始测试覆盖
Step 1: Run accelint-ts-testing skill
bash
/skill accelint-ts-testing <file-path>Step 2: Interactive Changes
BLOCKING - Interactive Approval Required:
You MUST complete all three checkpoints before proceeding:
- ✅ Display emoji severity table with ALL issues (see "Interactive Change Approval Pattern")
- ✅ Show detailed before/after code for EVERY issue
- ✅ Ask "Apply which issues?" with numbered list acceptance NO EXCEPTIONS. If you skip any checkpoint, you are violating the workflow.
- Apply accepted changes
- BLOCKING REQUIREMENT: If property-based tests added, run verification:
bash
# Run test suite 100 times to verify PBT stability for i in {1..100}; do <test-command> || break; done- Run the tests without coverage reporting to prevent coverage conflicts
- If ANY run fails, examine the seed that failed
- Fix test properties (add constraints to arbitraries: date ranges, filtered NaNs, safe strings)
- Re-run 100 times until 100 consecutive passes achieved
- DO NOT proceed to Step 3 until this verification passes
- Document findings in "Current File - Detailed Progress" section
- Update status to show Step 1 ✅, Step 2 ✅
- SAVE PROGRESS to audit-process file NOW before continuing
步骤1:运行accelint-ts-testing Skill
bash
/skill accelint-ts-testing <file-path>步骤2:交互式变更处理
强制要求 - 需要交互式审批:
继续流程前必须完成全部3个检查点:
- ✅ 展示包含所有问题的表情符号严重等级表格(参考「交互式变更审批模式」)
- ✅ 展示每个问题的详细代码变更前后对比
- ✅ 询问「要应用哪些问题的修复?」,支持编号列表选择 无任何例外。跳过任何检查点都属于违反工作流要求。
- 应用用户接受的变更
- 强制要求: 如果新增了PBT,运行以下校验:
bash
# 运行测试套件100次验证PBT稳定性 for i in {1..100}; do <test-command> || break; done- 运行测试时关闭覆盖率上报,避免覆盖率冲突
- 如果任何一次运行失败,检查失败的种子
- 修复测试属性(给任意值添加约束:日期范围、过滤NaN、安全字符串等)
- 重新运行100次,直到连续100次通过
- 校验通过前不要进入步骤3
- 在「当前文件 - 详细进度」部分记录发现的问题
- 更新状态,标记步骤1 ✅、步骤2 ✅
- 继续前务必将进度保存到审计流程文件
Phase 2: Code Quality & Performance Analysis
阶段2:代码质量与性能分析
Step 3: Run BOTH skills in parallel
CRITICAL: Run these together to avoid contradictory suggestions:
bash
/skill accelint-ts-best-practices <file-path>
/skill accelint-ts-performance <file-path>Step 4: Interactive Changes
- Review both sets of recommendations
- If recommendations overlap:
- Try to merge them into single fix if possible
- If conflicting, present both and let user choose
BLOCKING - Interactive Approval Required:
You MUST complete all three checkpoints before proceeding:
- ✅ Display emoji severity table with ALL issues from BOTH skills (see "Interactive Change Approval Pattern")
- ✅ Show detailed before/after code for EVERY issue
- ✅ Ask "Apply which issues?" with numbered list acceptance NO EXCEPTIONS. If you skip any checkpoint, you are violating the workflow.
- Apply accepted changes
- Add comments only where they add genuine insight
// PERF: - Document in "Current File - Detailed Progress"
- Update status to show Step 3 ✅, Step 4 ✅
- SAVE PROGRESS to audit-process file NOW before continuing
步骤3:并行运行两个Skill
关键要求:同时运行两个Skill,避免产生矛盾的建议:
bash
/skill accelint-ts-best-practices <file-path>
/skill accelint-ts-performance <file-path>步骤4:交互式变更处理
- 审查两组建议
- 如果建议重叠:
- 尽可能合并为单个修复
- 如果存在冲突,同时展示两个方案让用户选择
强制要求 - 需要交互式审批:
继续流程前必须完成全部3个检查点:
- ✅ 展示包含两个Skill返回的所有问题的表情符号严重等级表格(参考「交互式变更审批模式」)
- ✅ 展示每个问题的详细代码变更前后对比
- ✅ 询问「要应用哪些问题的修复?」,支持编号列表选择 无任何例外。跳过任何检查点都属于违反工作流要求。
- 应用用户接受的变更
- 仅在能提供真实价值的场景下添加注释
// PERF: - 在「当前文件 - 详细进度」部分记录内容
- 更新状态,标记步骤3 ✅、步骤4 ✅
- 继续前务必将进度保存到审计流程文件
Phase 3: Verify Changes
阶段3:变更校验
Step 5: Run verification commands
⚠️ CRITICAL: Use EXACT commands from audit-process file "Verification Commands" section. DO NOT improvise or run one-off commands.
Run ALL verification commands documented in audit-process file:
bash
undefined步骤5:运行校验命令
⚠️ 关键要求: 使用审计流程文件「校验命令」部分记录的准确命令,不要自行临时编写命令。
运行审计流程文件中记录的所有校验命令:
bash
undefinedExample commands (MUST match audit-process file exactly):
示例命令(必须和审计流程文件完全匹配):
cd <project-root>; npm test
cd <project-root>; npm run build
cd <project-root>; npm run lint
**Step 6: Interactive Changes (if needed)**
If verification passes, skip to documenting results. Otherwise:
**BLOCKING - Interactive Approval Required:**
> You MUST complete all three checkpoints before proceeding:
> 1. ✅ Display emoji severity table with ALL verification failures (see "Interactive Change Approval Pattern")
> 2. ✅ Show detailed before/after code for EVERY issue
> 3. ✅ Ask "Apply which fixes?" with numbered list acceptance
> NO EXCEPTIONS. If you skip any checkpoint, you are violating the workflow.
- Apply accepted changes
- Document results in "Current File - Detailed Progress"
- Update status to show Step 5 ✅, Step 6 ✅
- **SAVE PROGRESS to audit-process file NOW before continuing**cd <project-root>; npm test
cd <project-root>; npm run build
cd <project-root>; npm run lint
**步骤6:交互式变更处理(如果需要)**
如果校验通过,直接跳转到记录结果。否则:
**强制要求 - 需要交互式审批:**
> 继续流程前必须完成全部3个检查点:
> 1. ✅ 展示包含所有校验失败项的表情符号严重等级表格(参考「交互式变更审批模式」)
> 2. ✅ 展示每个问题的详细代码变更前后对比
> 3. ✅ 询问「要应用哪些修复?」,支持编号列表选择
> 无任何例外。跳过任何检查点都属于违反工作流要求。
- 应用用户接受的变更
- 在「当前文件 - 详细进度」部分记录结果
- 更新状态,标记步骤5 ✅、步骤6 ✅
- **继续前务必将进度保存到审计流程文件**Phase 4: Documentation
阶段4:文档处理
Step 7: Run accelint-ts-documentation skill
bash
/skill accelint-ts-documentation <file-path>Step 8: Interactive Changes
BLOCKING - Interactive Approval Required:
You MUST complete all three checkpoints before proceeding:
- ✅ Display emoji severity table with ALL documentation issues (see "Interactive Change Approval Pattern")
- ✅ Show detailed before/after code for EVERY issue
- ✅ Ask "Apply which issues?" with numbered list acceptance NO EXCEPTIONS. If you skip any checkpoint, you are violating the workflow.
- Apply accepted changes
- Run final verification to ensure docs didn't break anything (use EXACT commands from audit-process file)
- Document in "Current File - Detailed Progress"
- Update status to show Step 7 ✅, Step 8 ✅
- SAVE PROGRESS to audit-process file NOW before continuing to Step 3 (Archive)
步骤7:运行accelint-ts-documentation Skill
bash
/skill accelint-ts-documentation <file-path>步骤8:交互式变更处理
强制要求 - 需要交互式审批:
继续流程前必须完成全部3个检查点:
- ✅ 展示包含所有文档问题的表情符号严重等级表格(参考「交互式变更审批模式」)
- ✅ 展示每个问题的详细代码变更前后对比
- ✅ 询问「要应用哪些问题的修复?」,支持编号列表选择 无任何例外。跳过任何检查点都属于违反工作流要求。
- 应用用户接受的变更
- 运行最终校验,确保文档修改没有破坏任何功能(使用审计流程文件中记录的准确命令)
- 在「当前文件 - 详细进度」部分记录内容
- 更新状态,标记步骤7 ✅、步骤8 ✅
- 进入步骤3(归档)前务必将进度保存到审计流程文件
Step 3: Archive Completed File
步骤3:归档已完成文件
When all 9 steps complete for a file:
-
Move detailed progress to history file
- Copy entire "Current File - Detailed Progress" section
- Append to audit-history file
- Add summary statistics at end of file's section
-
Update audit-process file
- Mark file as "Completed" in "Files to Audit" section
- Clear "Current File - Detailed Progress" section
- Set "Current File" to next pending file
- Update "Resume Instructions" for next file
- Update "Current Status" counts
-
Save both files
单个文件的全部9个步骤完成后:
-
将详细进度移动到历史文件
- 复制整个「当前文件 - 详细进度」部分
- 追加到审计历史文件
- 在该文件部分的末尾添加汇总统计信息
-
更新审计流程文件
- 在「待审计文件」部分将该文件标记为「已完成」
- 清空「当前文件 - 详细进度」部分
- 将「当前文件」设置为下一个待处理文件
- 更新「恢复指引」内容,适配下一个文件
- 更新「当前状态」计数
-
保存两个文件
Step 4: Continue or Complete
步骤4:继续流程或完成审计
If more pending files exist:
- Return to Step 2 for next file
- Monitor context usage - if approaching limit, stop and save progress
If all files completed:
-
Run final verification in worktree:
- Run final full test suite + lint verification
- Ensure all changes pass before merging
-
Merge worktree back to original branch:bash
# Extract timestamp from current worktree directory name # We're in .agents/worktrees/audit-YYYYMMDD-HHMMSS timestamp=$(basename $(pwd) | sed 's/audit-//') # Get the original branch from this audit's process file (in original repo) repo_root=$(git rev-parse --show-toplevel) audit_process_file="${repo_root}/.agents/audit/audit-process-${timestamp}.md" original_branch=$(grep "^**Original Branch:**" ${audit_process_file} | cut -d'`' -f2) # Commit all changes in worktree git add -A git commit -m "refactor: complete TypeScript audit - Improved test coverage across all files - Applied type safety and best practice improvements - Optimized performance where beneficial - Enhanced documentation Co-Authored-By: {current_model}" # Switch back to original branch cd "${repo_root}" git checkout ${original_branch} # Merge the audit branch git merge --no-ff audit/${timestamp} -
Clean up worktree:bash
# Remove the worktree (use the timestamp extracted earlier) git worktree remove .agents/worktrees/audit-${timestamp} # Optionally delete the audit branch git branch -d audit/${timestamp} -
Update audit-process file with completion:
- Add completion summary with total statistics
- Document merge commit hash
- Mark audit as "✅ COMPLETE - Merged to ${original_branch}"
-
Report results:
- Total statistics across all files
- Merge commit information
- Confirmation that worktree was cleaned up
如果还有待处理文件:
- 回到步骤2处理下一个文件
- 监控上下文使用情况,如果接近限制则停止并保存进度
如果所有文件都已完成:
-
在worktree中运行最终校验:
- 运行最终的全量测试套件+lint校验
- 合并前确保所有变更都通过校验
-
将worktree合并回原分支:bash
# 从当前worktree目录名提取时间戳 # 当前目录为 .agents/worktrees/audit-YYYYMMDD-HHMMSS timestamp=$(basename $(pwd) | sed 's/audit-//') # 从本次审计的流程文件(原仓库中)获取原分支 repo_root=$(git rev-parse --show-toplevel) audit_process_file="${repo_root}/.agents/audit/audit-process-${timestamp}.md" original_branch=$(grep "^**Original Branch:**" ${audit_process_file} | cut -d'`' -f2) # 在worktree中提交所有变更 git add -A git commit -m "refactor: complete TypeScript audit - Improved test coverage across all files - Applied type safety and best practice improvements - Optimized performance where beneficial - Enhanced documentation Co-Authored-By: {current_model}" # 切换回原分支 cd "${repo_root}" git checkout ${original_branch} # 合并审计分支 git merge --no-ff audit/${timestamp} -
清理worktree:bash
# 删除worktree(使用之前提取的时间戳) git worktree remove .agents/worktrees/audit-${timestamp} # 可选择删除审计分支 git branch -d audit/${timestamp} -
更新审计流程文件,标记完成:
- 添加包含总统计信息的完成汇总
- 记录合并提交哈希
- 标记审计为「✅ 已完成 - 已合并到 ${original_branch}」
-
上报结果:
- 所有文件的总统计信息
- 合并提交信息
- 确认worktree已清理完成
Progress Tracking Format
进度追踪格式
File Status Markers:
- - Pending (not started)
[ ] - - Completed (all 9 steps done, moved to history)
[x]
Step Status Markers:
- ✅ - Complete
- 🔄 - In Progress
- ⏸️ - Pending (not started)
Detailed Progress Template:
markdown
undefined文件状态标记:
- - 待处理(未开始)
[ ] - - 已完成(全部9步已完成,已移动到历史文件)
[x]
步骤状态标记:
- ✅ - 已完成
- 🔄 - 进行中
- ⏸️ - 待处理(未开始)
详细进度模板:
markdown
undefinedfilename.ts - Audit Status 🔄 IN PROGRESS
filename.ts - 审计状态 🔄 进行中
Overall Progress: X% complete (Step Y of 8)
整体进度: X% 已完成(第Y步,共8步)
✅ Step 1: Test Coverage - COMPLETE
✅ 步骤1:测试覆盖 - 已完成
[Findings, changes applied, test results]
[发现的问题、应用的变更、测试结果]
🔄 Step 2: Interactive Changes - IN PROGRESS
🔄 步骤2:交互式变更 - 进行中
[Current change being reviewed, user decision needed]
[当前正在评审的变更、需要用户决策的内容]
⏸️ Step 3: Code Quality Analysis - PENDING
⏸️ 步骤3:代码质量分析 - 待处理
[Not started yet]
undefined[尚未开始]
undefinedInteractive Change Approval Pattern
交互式变更审批模式
CRITICAL: Always use the two-phase presentation pattern. NEVER present issues one-by-one or ask for approval before showing all changes.
关键要求: 始终使用两阶段展示模式。绝对不要逐个展示问题,也不要在展示所有变更前要求审批。
Phase 1: Overview Table (Quick Scan)
阶段1:概览表格(快速扫描)
Present ALL issues in a numbered table using emoji severity indicators:
markdown
undefined使用表情符号严重等级指示器,以编号表格形式展示所有问题:
markdown
undefinedFound Issues Summary (X total)
发现问题汇总(共X个)
| # | Severity | Type | Lines | Description |
|---|---|---|---|---|
| 1 | 🛑 Critical | Type Safety | 45-47 | Missing null check on user object |
| 2 | ⚠️ High | Performance | 89 | N+1 query in loop - use batch fetch |
| 3 | ⚡ Medium | Performance | 120-125 | Filter+map → single pass with reduce |
| 4 | 🔵 Low | Best Practice | 78 | Use const assertion for readonly array |
| 5 | ✅ Info | Documentation | 12 | Missing JSDoc return type |
**Severity Legend:**
- 🛑 **Critical** - Causes runtime errors, security vulnerabilities, or data loss
- ⚠️ **High** - Type errors, significant performance issues, or API breaking changes
- ⚡ **Medium** - Moderate performance gains, maintainability improvements
- 🔵 **Low** - Minor optimizations, style improvements
- ✅ **Info** - Documentation, comments, non-functional improvements| # | 严重等级 | 类型 | 行号 | 描述 |
|---|---|---|---|---|
| 1 | 🛑 严重 | 类型安全 | 45-47 | user对象缺少空值检查 |
| 2 | ⚠️ 高 | 性能 | 89 | 循环中存在N+1查询 - 使用批量获取 |
| 3 | ⚡ 中等 | 性能 | 120-125 | Filter+map → 用reduce单遍处理 |
| 4 | 🔵 低 | 最佳实践 | 78 | 只读数组使用const断言 |
| 5 | ✅ 信息 | 文档 | 12 | 缺少JSDoc返回类型 |
**严重等级说明:**
- 🛑 **严重** - 会导致运行时错误、安全漏洞或数据丢失
- ⚠️ **高** - 类型错误、显著性能问题或API破坏性变更
- ⚡ **中等** - 中度性能提升、可维护性改进
- 🔵 **低** - minor优化、风格改进
- ✅ **信息** - 文档、注释、非功能性改进Phase 2: Detailed Changes (Full Context)
阶段2:详细变更(完整上下文)
After showing the overview table, display each issue with complete before/after code:
markdown
---展示概览表格后,逐个展示每个问题的完整代码变更前后对比:
markdown
---Issue #1: Missing null check (🛑 Critical - Type Safety)
问题#1:缺少空值检查(🛑 严重 - 类型安全)
Lines: 45-47
Problem: Function doesn't handle null user case
Impact: Runtime TypeError when user is null
❌ Before:
typescript
function getUsername(user: User | null) {
return user.name; // TS error + runtime crash
}✅ After:
typescript
function getUsername(user: User | null) {
return user?.name ?? 'Anonymous';
}Expected Benefit: Prevents runtime TypeError, fixes TS compilation error
行号: 45-47
问题: 函数没有处理user为null的场景
影响: user为null时会触发运行时TypeError
❌ 修改前:
typescript
function getUsername(user: User | null) {
return user.name; // TS错误 + 运行时崩溃
}✅ 修改后:
typescript
function getUsername(user: User | null) {
return user?.name ?? 'Anonymous';
}预期收益: 避免运行时TypeError,修复TS编译错误
Issue #2: N+1 Query Performance (⚠️ High - Performance)
问题#2:N+1查询性能问题(⚠️ 高 - 性能)
[... same detailed format for each issue ...]
[... 每个问题都使用相同的详细格式 ...]
Issue #3: Filter+map optimization (⚡ Medium - Performance)
问题#3:Filter+map优化(⚡ 中等 - 性能)
[... same detailed format for each issue ...]
[Continue for all issues...]
Apply which issues? Enter numbers (e.g., "1, 2, 5" or "all" or "skip"):
**Key Benefits:**
- Overview table allows quick scanning for conflicts across parallel processes
- Numbered list makes acceptance explicit and trackable
- All code changes shown upfront before any approval
- Emoji severity indicators enable instant visual prioritization
- Consistent format prevents wildly varying presentations
Wait for user response with numbered list before applying any changes.[... 每个问题都使用相同的详细格式 ...]
[所有问题依次展示...]
要应用哪些问题的修复? 输入编号(例如:"1, 2, 5" 或 "all" 或 "skip"):
**核心优势:**
- 概览表格支持快速扫描并行流程产生的冲突
- 编号列表让接受操作更明确可追踪
- 所有代码变更在审批前全部提前展示
- 表情符号严重等级指示器支持即时可视化优先级排序
- 统一格式避免展示方式混乱
应用任何变更前等待用户返回编号列表选择。Verification Commands
校验命令
The audit-process file MUST document exact verification commands. Common patterns:
Node.js projects:
bash
cd <project-root>; npm test
cd <project-root>; npm run build
cd <project-root>; npm run lintBun projects:
bash
cd <project-root>; bun run test
cd <project-root>; bun run build
cd <project-root>; bun run lint
cd <project-root>; bun run bench # if applicableMonorepo packages:
bash
cd <workspace-root>/packages/<package-name>; npm testAlways use the EXACT commands from the audit-process file. Never guess.
审计流程文件必须记录准确的校验命令。常见模式:
Node.js项目:
bash
cd <project-root>; npm test
cd <project-root>; npm run build
cd <project-root>; npm run lintBun项目:
bash
cd <project-root>; bun run test
cd <project-root>; bun run build
cd <project-root>; bun run lint
cd <project-root>; bun run bench # 如适用Monorepo包:
bash
cd <workspace-root>/packages/<package-name>; npm test始终使用审计流程文件中记录的准确命令,不要猜测。
Important Notes
重要注意事项
- Do NOT load README.md - It contains user-facing documentation that duplicates this file. All Agent instructions are contained in SKILL.md.
- Worktree location: All audit work happens in to avoid conflicts with the gitignored
.agents/worktrees/audit-${timestamp}directory..agents/audit/ - Tracking files location: Audit process and history files are stored in the original repository's directory (gitignored) and are NOT committed with audit changes.
.agents/audit/ - Property-based test stability: If property tests fail randomly, check the exact seed that failed and verify the fix against that seed. Add constraints to arbitraries (date ranges, filtered NaNs, safe strings) to prevent false positives.
- Parallel skill execution: When running ts-best-practices and ts-performance in parallel, wait for BOTH to complete before presenting recommendations. This allows you to identify and merge overlapping suggestions.
- Context window management: Audit-process files are designed to survive context limits. After completing each step, save progress. If you must stop mid-file, document exactly which step you're on and what the next action should be.
- Build failures block progress: Never proceed to the next step if verification commands fail. Fix the issue or roll back the change first.
- PERF comment guidelines: Only add performance comments when the optimization is non-obvious. "Using for...of instead of map" doesn't need a comment. "Memoizing deserializer to avoid repeated JSON parsing" does.
- History file is write-only: Only read audit-history file if you need to understand a previous decision or consider reverting a change. Otherwise, it's purely archival.
- 不要加载README.md - 其中包含面向用户的文档,和本文件内容重复。所有Agent指令都包含在SKILL.md中。
- Worktree位置: 所有审计工作在目录开展,避免和git忽略的
.agents/worktrees/audit-${timestamp}目录产生冲突。.agents/audit/ - 追踪文件位置: 审计流程和历史文件存放在原仓库的目录(被git忽略),不会随审计变更一起提交。
.agents/audit/ - PBT稳定性: 如果属性测试随机失败,检查失败的具体种子,针对该种子验证修复方案。给任意值添加约束(日期范围、过滤NaN、安全字符串等)避免误报。
- 并行Skill执行: 并行运行ts-best-practices和ts-performance时,等待两个Skill都完成后再展示建议,这样可以识别并合并重叠的建议。
- 上下文窗口管理: 审计流程文件设计为可应对上下文限制,每个步骤完成后保存进度。如果必须在文件处理中途停止,明确记录当前处于哪个步骤,以及下一步操作是什么。
- 构建失败会阻塞进度: 如果校验命令失败,绝对不要进入下一个步骤,先修复问题或回滚变更。
- PERF注释规范: 仅当优化不直观时才添加性能注释。「使用for...of替代map」不需要注释,「缓存反序列化结果避免重复JSON解析」需要注释。
- 历史文件是只读归档: 只有需要了解之前的决策或考虑回滚变更时才读取审计历史文件,其他情况下仅作为归档使用。