patterns/codebase-audit/skills/codebase-audit-writer/SKILL.md
Writer CSA for deep crate analysis — generates README, review report, blog, and facts.toml
npx skillsauth add ryderfreeman4logos/cli-sub-agent codebase-audit-writerInstall 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:
csa run, csa review, csa debate, or ANY csa command.Analyze a single crate's source code and produce four outputs:
# Machine-readable crate analysis sidecar
[metadata]
crate_name = "csa-core"
analyzed_at = "2026-03-19T05:00:00Z"
source_lines = 2500
source_files = 12
[[exported_apis]]
name = "SessionId::new"
signature = "pub fn new() -> Self"
module = "session"
description = "Create a new ULID-based session identifier"
[[key_types]]
name = "SessionPhase"
kind = "enum"
visibility = "pub"
description = "State machine: Active, Available, Retired"
variants = ["Active", "Available", "Retired"]
[[constraints]]
description = "SessionId must be a valid ULID"
enforced_by = "SessionId::new() uses ulid::Ulid::new()"
scope = "constructor"
[[risks]]
severity = "medium"
description = "No validation on deserialized SessionId strings"
location = "session.rs:42"
suggestion = "Add TryFrom<String> with ULID validation"
[dependency_summary]
direct_deps = ["ulid", "serde", "thiserror"]
workspace_deps = []
summary = "Core domain types with no workspace dependencies (L0 crate)"
# {crate_name} — {one-line Chinese description}
## Architecture Overview
{Chinese prose: design philosophy, module structure, key decisions}
## Public API Index
| API | Module | Description |
|-----|--------|-------------|
| `fn_name(args) -> Ret` | module | Chinese description |
## Key Types
### TypeName
{Chinese description with code examples}
## Usage Examples
{Code snippets showing common usage patterns}
## Internal Structure
{Module dependency diagram if >5 modules}
Chapter splitting rule: If README.md would exceed 1000 lines, create:
README.md as table of contents with links to chapterschapters/01-architecture.md, chapters/02-public-api.md, etc.# Code Review: {crate_name}
## Summary
{1-paragraph Chinese overview of code quality}
## Quality Assessment
### Error Handling
{Analysis with line references}
### Naming Conventions
{Analysis of identifier naming quality}
### Module Structure
{Is the module hierarchy clean? Pass-through methods? Shallow modules?}
## Security Analysis
### Input Validation
{Public API parameter validation}
### Unsafe Usage
{List all unsafe blocks, verify SAFETY comments}
### Resource Limits
{Unbounded allocations, missing timeouts}
## Performance Observations
{Hot paths, unnecessary allocations, iterator vs index patterns}
## Recommendations
1. {Priority-ordered improvement suggestions}
# {Chinese blog title about the crate}
{Technical deep-dive targeting intermediate Rust developers.
Cover design philosophy, interesting implementation patterns,
tradeoffs, and lessons. 800-1500 lines.}
file.rs:42 format. MUST be accurate — verify by reading the actual file.pub item must appear in facts.toml. Major public APIs must appear in README.md.This skill is invoked by the codebase-audit workflow. It is not meant to be called directly.
The workflow provides ${CRATE_DIR}, ${crate}, and ${DEPENDENCY_FACTS} variables.
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