[Documentation] Use when generating, smart-merging or refactoring the root AI context (CLAUDE.md, AGENTS.md) and its Claude/Codex projections. Config file only: project-config.
中文简介正在准备中。当前显示原文说明。
[Documentation] Use when detecting codebase health issues: unused exports, doc count-drift, orphan files, stale config references.
中文简介正在准备中。当前显示原文说明。
查看安装方法安装前可以查看交给 AI 代理的指令内容。
Review modes: For review/audit work, standalone defaults to
--review-only(--report-onlyalias);--fix-loopenables review → validate → authorized fix → fresh re-review, default cap 3.--fix-loop --loop-owner=callerreturns a read-only pass to the caller that owns fixes/re-review. Create triage, review, validation and re-review todo tasks first; apply the carriedreview-policycontract for LOW deferral and user-approved bounded extensions. Non-review modes and terminal findings validation keep their own dispatch.
Goal: Detect structural rot — dead code, count-drift, orphan files, stale configs, dead feature flags and broken cross-references — in AI-assisted codebases through docs/project-config.json, then report evidence-backed maintenance actions.
Summary: Classify scope/tooling → check doc counts, config references, unused exports, orphan files, pattern drift, feature flags and cross-references → fresh-eyes verification → report → actionable summary. Log graph/flag-dependent skips; retain optional CI detection.
Workflow:
tmp/reports/codebase-health-scan-{YYMMDD}.mdKey Rules:
.code-graph/graph.db not foundfile:line, category, severity (HIGH/MEDIUM/LOW), suggested action
MUST ATTENTION NEVER report a finding without file:line proofBefore any other step, in parallel:
docs/project-config.json for the codebaseHealth section:{
"codebaseHealth": {
"sourcePaths": ["{discovered-source-root}/"],
"docPaths": ["docs/"],
"configPatterns": ["**/appsettings*.json", "**/environment*.ts"],
"excludePaths": ["node_modules", "dist", "bin", "obj"]
}
}
If codebaseHealth section is missing, discover source roots from project config, manifests, and populated code directories; use docPaths: ["docs/"] when docs exist.
| Signal | Phase Enabled |
|---|---|
.code-graph/graph.db exists | Phase 3 (Unused Exports) + Phase 4 (Orphan Files) |
CI config found (.github/workflows, azure-pipelines.yml) | Phase 6 (CI Health) — optional |
Feature flag patterns found (FeatureFlags, IFeatureManager, LaunchDarkly) | Phase 6 (Dead Feature Flags) |
Cross-reference patterns in docs (file:line, [link]()) | Phase 7 (Broken Cross-References) |
TaskCreate entries for each enabled phase before proceeding.Evidence gate: If docs/project-config.json not found and no detectable source paths, report and ask user for guidance. DO NOT guess project structure.
Verify numeric claims against filesystem evidence; distinguish normal growth from maintenance drift using the thresholds below.
Scan docs/ and the AI-harness instruction surface when present (.claude/**/*.md, root AGENTS.md, CLAUDE.md) for numeric claims: "N files", "N tests", "N hooks", "N services", "N skills", "N components", "N stages", "N verifiers", "N agents", "N workflows". Derive harness counts by globbing .claude/ skill dirs, hook entries, scripts/**/verify-* scripts, pipeline stages, agent files and workflows.json entries. Prioritize these claims: artifact additions leave prose counts frozen. Apply to any .claude/ harness; never hardcode project or framework counts.
For each claim:
Severity thresholds:
Write findings incrementally to report after each doc scanned. NEVER batch at end.
Check whether configured code artifacts (class names, module names, connection strings) were renamed or deleted.
For each file matching configPatterns:
Evidence gate: NEVER flag a reference as stale without attempting grep. Confidence <80% → flag as MEDIUM "unverified" only.
Skip if .code-graph/graph.db does not exist — log "Phase 3 skipped: no graph.db".
Distinguish dead public API from intentional entry points by file type.
For key exported symbols in source files:
python .claude/scripts/code_graph query importers_of <symbol> --jsonSkip if .code-graph/graph.db does not exist — log "Phase 4 skipped: no graph.db".
Find source files (.ts,.cs,.py, etc.) with zero inbound edges:
python .claude/scripts/code_graph query importers_of <file> --jsonCompare patterns across services/modules, distinguishing intentional from accidental divergence:
Skip if no feature flag patterns found in Phase 0.
Check doc links and file:line references for missing or stale targets.
For docs containing markdown links [text](path) or file:line references:
Before writing final report, spawn a fresh sub-agent (zero memory) to:
file:line evidence sourceMax 3 review rounds → escalate to user if review finds >30% false positive rate.
Write to tmp/reports/codebase-health-scan-{YYMMDD}.md:
# Codebase Health Scan Report
**Date:** {YYYY-MM-DD}
**Phases Completed:** {N}/{total} ({reason for skipped phases})
**Findings:** {total} ({HIGH} high, {MEDIUM} medium, {LOW} low)
## Summary
| Phase | Status | Findings |
| ----------------------- | ----------------------------------- | ---------- |
| Doc Count-Drift | Scanned | N findings |
| Stale Config Refs | Scanned | N findings |
| Unused Exports | Scanned/Skipped (no graph.db) | N findings |
| Orphan Files | Scanned/Skipped (no graph.db) | N findings |
| Pattern Drift | Scanned | N findings |
| Dead Feature Flags | Scanned/Skipped (no flags detected) | N findings |
| Broken Cross-References | Scanned | N findings |
## Findings
### HIGH Severity
- `{file}:{line}`: {description} — Action: {action}
### MEDIUM Severity
- `{file}:{line}`: {description} — Action: {action}
### LOW Severity
- `{file}:{line}`: {description} — Action: {action}
## False Positives (Fresh-Eyes Review)
{Findings dismissed by Round 2 review with reasoning}
<!-- PROTOCOL-GUIDES:START -->[IMPORTANT] Use
TaskCreateto break ALL work into small tasks BEFORE starting.
Protocol guides — Apply each protocol only when its read-when condition holds. If a protocol's text is not in your context, read its file below before you act on it.
output-quality-principles — Readable guidance and verified contents for long skill/doc files; writing, updating or auditing a skill or reference document, or another Markdown artifact over 200 lines → .claude/skills/shared/protocols/output-quality-principles.mdreview-decision-autonomy — Choose supported review decisions and ask before extending the round budget; running any review or audit skill or mode → .claude/skills/shared/protocols/review-decision-autonomy.mdreview-policy — Review-only or a three-round fix loop with explicit extension and fresh post-fix evidence; deciding round eligibility, blocking findings or review state → .claude/skills/shared/protocols/review-policy.mdIMPORTANT MUST ATTENTION lead with useful guidance and readable priorities; preserve action-changing conditions/numbers and required structures. When writing, updating or auditing Markdown skill/doc content, verify top, heading-linked contents over 200 lines (stricter owner thresholds remain); refresh after edits and report gaps in read-only audits. Remove report bulk; judge semantic value rather than word counts.
<!-- /SYNC:output-quality-principles:reminder --> <!-- SYNC:review-decision-autonomy:reminder -->MUST ATTENTION Decide supported review choices and recommendations, record the rationale, and finish without routine user questions. Keep round-limit extension, indispensable facts and actual action authority; preserve source coverage, validation, tests, read-only boundaries and budgets. Review decisions do not accept open risks or make a failed gate pass.
<!-- /SYNC:review-decision-autonomy:reminder -->IMPORTANT MUST ATTENTION Goal: Detect structural rot — dead code, count-drift, orphan files, stale configs, dead feature flags and broken cross-references — in AI-assisted codebases through docs/project-config.json, then report evidence-backed maintenance actions.
MUST ATTENTION Main steps: classify scope/tooling → doc counts → config references → unused exports → orphan files → pattern drift → feature flags → cross-references → fresh-eyes verification → report → actionable summary. Log graph/flag-dependent skips and retain optional CI detection.
IMPORTANT MUST ATTENTION break work into small TaskCreate tasks BEFORE starting — one per phase
MUST ATTENTION — Protocols in force (concise digest of the SYNC/shared blocks this skill carries):
IMPORTANT MUST ATTENTION detect available tooling in Phase 0 — never assume graph.db exists
IMPORTANT MUST ATTENTION NEVER report a finding without file:line evidence
IMPORTANT MUST ATTENTION write findings incrementally after each phase — NEVER batch at end
IMPORTANT MUST ATTENTION severity thresholds are concrete: HIGH = runtime failure risk; MEDIUM = drift/dead code; LOW = cleanup candidate
IMPORTANT MUST ATTENTION Phase 8 fresh-eyes review is mandatory — prevents false positives from rationalization
Anti-Rationalization:
| Evasion | Rebuttal |
|---|---|
| "Graph not needed, skip Phases 3-4" | Phases 3-4 are explicitly gated — state skip reason in report, don't silently omit |
| "Count drift is small, LOW severity is fine" | Apply the threshold table: >10% = MEDIUM, >30% = HIGH. No discretionary override. |
| "Finding looks valid, skip Round 2 review" | Main agent rationalizes own findings. Fresh-eyes is non-negotiable. |
| "No feature flags found, skip Phase 6" | Log "Phase 6 skipped: no feature flag patterns detected" in report |
| "Config reference might still exist" | Grep to verify. Confidence <80% → flag as MEDIUM "unverified" not LOW "probably fine" |
[TASK-PLANNING] Before acting, analyze task scope and break into small todo tasks and sub-tasks using TaskCreate.
<!-- SYNC:review-policy:reminder -->MUST ATTENTION Triage all targets, plan and create review/validation/fix/fresh re-review tasks first. Review-only reports without edits; fix-loop freshly reviews every repair under one fixing owner. Default cap three rounds: disclose deferred LOWs, ask and wait before a bounded extension for MEDIUM+ or failed required checks. Preserve scope, coverage and actual operation authority.
<!-- /SYNC:review-policy:reminder -->还没有评价。欢迎分享你的使用感受。
无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。
还没有评论。来写第一条吧。
[Documentation] Use when generating, smart-merging or refactoring the root AI context (CLAUDE.md, AGENTS.md) and its Claude/Codex projections. Config file only: project-config.
中文简介正在准备中。当前显示原文说明。
[Code Quality] Use when a workflow step or the user asks for AI code or plan review: LLM calls, prompts, agents, RAG, evals and guardrails. --mode={code|plan}; --report-only is read-only.
中文简介正在准备中。当前显示原文说明。
[Architecture] Use when a workflow step or the user asks for architecture design, compliance review, scalability grading or whole-project audit via --mode={design|review|scalability|full}.
中文简介正在准备中。当前显示原文说明。
[Content] Use when a workflow step or the user asks for product/feature ideation with ranked opportunities and validation tests. --mode={roadmap|scope}.
中文简介正在准备中。当前显示原文说明。
[Content] Use when a workflow step or the user asks for business viability: Business Model Canvas, financials, risks and go-to-market recommendation.
中文简介正在准备中。当前显示原文说明。
[Code Quality] Use when a workflow step or the user asks for a focused code-change review: staged, unstaged, branch diff or simple pull request. --fix-loop fixes and re-reviews. Complex pull request: workflow-review-changes; rationale: why-review.
中文简介正在准备中。当前显示原文说明。