patterns/codebase-audit/skills/codebase-audit/SKILL.md
Use when: deep per-crate code audit, Chinese documentation generation
npx skillsauth add ryderfreeman4logos/cli-sub-agent codebase-auditInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Role MUST be determined by explicit mode marker, not fragile natural-language substring matching.
Treat the run as executor ONLY when initial prompt contains:
<skill-mode>executor</skill-mode>.
YOU ARE THE EXECUTOR. Follow these rules:
../../PATTERN.md relative to this SKILL.md. Execute Tool: bash
steps directly. Steps marked Tool: csa are dispatched by the orchestrator — skip them
and report that they require orchestrator dispatch.csa run, csa review, csa debate, or ANY csa command.Only if you are the main agent (Claude Code / human user):
Perform a systematic, bottom-up deep analysis of an entire codebase (or scoped subset), generating three types of Chinese documentation per crate:
Plus a machine-readable facts.toml sidecar per crate containing exported APIs, key types, constraints, risks, and dependency summaries.
Crates are processed in topological order (leaf dependencies first) so downstream analysis inherits upstream facts. Large crates are automatically sharded to stay within the 163,840 token context budget. A dual CSA Writer+Reviewer pipeline ensures factual accuracy.
scripts/crate-topo.sh must exist (generates topological crate order)csa run --sa-mode true --skill codebase-audit "Analyze all crates in the workspace"
csa plan run currently skips loop_var steps (unsupported in the plan executor).
The orchestrator (this skill's executor) MUST implement the FOR loop manually:
# Step 1: Get crate list
CRATE_LIST=$(bash scripts/crate-topo.sh)
# Step 2-3: Prepare and estimate
# Step 4-7: FOR each crate — orchestrator iterates manually
IFS=',' read -ra CRATES <<< "$CRATE_LIST"
for crate in "${CRATES[@]}"; do
# Run Writer CSA
csa run --sa-mode true --tier tier-4-critical --timeout 3600 \
"Analyze crate ${crate} at crates/${crate}/src/ ..."
# Run Reviewer CSA
csa run --sa-mode true --tier tier-4-critical --timeout 2400 \
"Review drafts/crates/${crate}/ against crates/${crate}/src/ ..."
done
The workflow.toml remains the authoritative step definition; the orchestrator translates loop steps into sequential CSA calls.
When operating under SA mode, ALL csa invocations MUST include --sa-mode true.
scripts/crate-topo.sh produces comma-separated crate list in dependency order.drafts/crates/{crate}/chapters/ directories and progress.toml.tokuin estimate per crate, mark large crates for sharding (>80K tokens).Fully resumable. If interrupted:
grep 'status = "pending"' drafts/crates/progress.toml shows remaining work| Command | Effect |
|---------|--------|
| /codebase-audit | Analyze all crates in topological order |
scripts/crate-topo.sh, cargo metadata, jqfile-audit (AGENTS.md compliance), codebase-blog (blog generation from audit)drafts/crates/ directory with per-crate documentation + global SUMMARY.mdcargo metadata (not file-level topo).drafts/crates/ mirroring crate structure.progress.toml shows all crates completed.SUMMARY.md generated with cross-crate analysis and Mermaid diagram.development
Use when running a non-blocking CSA background code health scan that uses csa health and csa tokuin estimate to propose refactoring GitHub issues for files over token or complexity thresholds.
data-ai
Recover main-agent context after `/clear`, `/compact`, or lost local thread state by using `csa recall` against recorded Claude main sessions.
tools
Use when: merged PR had HIGH/CRITICAL findings that represent a bug class — extracts reusable coding rule
tools
Use when: review found 2+ independent findings in different files, fix phase can parallelize RECON