Awesome-omni-skill code-audit
Perform a human-assisted code audit. Use when asked to audit, review architecture, document a codebase, or create technical documentation with diagrams.
git clone https://github.com/diegosouzapw/awesome-omni-skill
T=$(mktemp -d) && git clone --depth=1 https://github.com/diegosouzapw/awesome-omni-skill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/development/code-audit" ~/.claude/skills/diegosouzapw-awesome-omni-skill-code-audit && rm -rf "$T"
skills/development/code-audit/SKILL.mdCode Audit Skill
This skill guides a structured, bottom-up code audit process that produces clear documentation with PlantUML diagrams.
Quick Reference
| Phase | Action |
|---|---|
| 0 | Initialize or resume audit |
| 1 | Define scope (boundaries, aspects) |
| 2 | Analyze components bottom-up |
| 3 | Synthesize findings into docs/diagrams |
| 4 | Human review and finalization |
Invocation
All audits are stored in
code-audits/ relative to the current working directory.
Directory naming:
code-audits/<system-title>-YYMMDD/
- Example:
code-audits/redemption-service-250106/
When invoked:
- Check
for existing audits withcode-audits/state.json - If found, list them and offer to resume
- If starting fresh, ask for a short system title (kebab-case), then create directory
Output Directory Structure
<audit-dir>/ ├── state.json # Tracks progress for resumption ├── index.md # Main audit index (created in Phase 3) ├── boundaries.md # Scope definition (created in Phase 1) ├── entry-points.md # System entry points (created in Phase 3) ├── techdebt.md # TODOs and technical debt (created in Phase 3) ├── components/ # Per-file summaries (created in Phase 2) ├── aspects/ # Cross-cutting concerns (created in Phase 3) ├── diagrams/ # PlantUML source files (created in Phase 3) └── generated/ # Post-processed with SVGs (created in Phase 4)
State File Format
{ "version": 1, "title": "redemption-service", "phase": "scoping|discovery|synthesis|review|complete", "boundaries": { "directories": ["app/services/**"], "files": [], "excludes": ["**/*_test.rb", "**/*.spec.ts"] }, "aspects": ["error-handling", "retry-patterns", "execution-contexts", "authorization"], "components": { "app/services/foo.rb": { "status": "pending|in_progress|complete", "summary_file": "components/app-services-foo.md" } }, "checkpoint_interval": 5, "created_at": "2024-01-01T00:00:00Z", "updated_at": "2024-01-01T00:00:00Z" }
Required Focus Areas
Every audit MUST document these cross-cutting concerns:
- Error Handling - How errors are caught, propagated, logged, and recovered from
- Retry Patterns - Any retry logic, backoff strategies, idempotency handling
- Execution Contexts - How code is invoked (web request, background job, scheduler, CLI, etc.)
- Authorization - Access control, permission checks, authentication requirements
- Testing Patterns - Test coverage approach, test types used, mocking strategies, what's tested vs. not
- Database Patterns - Transactions, queries, migrations, connection management, N+1 risks
- Configuration & Secrets - Environment variables, feature flags, secrets management, config loading
- Logging & Observability - Log levels, structured logging, tracing, metrics, health checks
- Concurrency & Thread Safety - Locks, async patterns, race condition risks, thread pools
- External Integrations - API clients, webhooks, third-party services, failure handling
Phase Workflow
See
workflow.md for detailed instructions on each phase.
Use subagents/tasks for individual, isolated task execution to maintain efficient context.
Phase 0: Initialize/Resume
-
Check for existing audits in
:code-audits/- Look for directories containing
state.json - If found, list them with their phase and progress
- Offer to resume any incomplete audit
- Look for directories containing
-
If resuming:
- Read and parse
state.json - Jump to the current phase
- Read and parse
-
If starting fresh:
- Ask for a short system title (kebab-case, e.g., "redemption-service")
- Generate directory name:
code-audits/<title>-YYMMDD/ - Create directory structure:
mkdir -p code-audits/<title>-YYMMDD/{components,aspects,diagrams,generated} - Initialize
with phase="scoping"state.json - Proceed to Phase 1
Phase 1: Scoping
Use
AskUserQuestion to gather:
-
Boundaries: Which directories/files to include
- Accept glob patterns (e.g.,
)app/services/**/*.rb - Can be specific files or broad directories
- Accept glob patterns (e.g.,
-
Excludes: What to skip
- Tests, generated files, vendor code, etc.
-
Additional Aspects: Beyond the 4 required ones
- Performance patterns, caching, external integrations, etc.
Then:
- Write
documenting the scopeboundaries.md - Update
with boundaries and aspectsstate.json - Set phase to "discovery"
Phase 2: Discovery (Bottom-Up)
- Enumerate all files matching boundaries (respecting excludes)
- Register each in
with status "pending"state.json - Use
to track progressTodoWrite
For each file:
- Mark "in_progress" in state
- Read and analyze the code
- Create component summary in
using the templatecomponents/ - Mark "complete" in state
- Every N files (checkpoint_interval), pause and ask user to verify
When all components complete:
- Update phase to "synthesis"
Phase 3: Synthesis
-
Read all component summaries
-
Identify patterns across components
-
Create aspect documentation:
aspects/error-handling.mdaspects/retry-patterns.mdaspects/execution-contexts.mdaspects/authorization.mdaspects/testing-patterns.mdaspects/database-patterns.mdaspects/configuration-secrets.mdaspects/logging-observability.mdaspects/concurrency-thread-safety.mdaspects/external-integrations.md- Plus any user-specified aspects
-
Create
documenting:entry-points.md- Where external requests enter the system (routes, endpoints, CLI)
- Background job entry points
- Scheduled task triggers
- Event/webhook handlers
- Recommended reading order for newcomers
-
Create
consolidating:techdebt.md- TODOs and FIXMEs found in code
- Deprecated patterns still in use
- Known issues and workarounds
- Suggested improvements from component analysis
-
Design PlantUML diagrams:
- Architecture overview (component relationships)
- Data flow diagrams (how data moves through system)
- Sequence diagrams (for key flows)
- State diagrams (where relevant)
-
Write
tying everything togetherindex.md -
Update phase to "review"
Phase 4: Review
- Present audit summary to user
- Walk through each aspect
- Show diagram previews (describe what they show)
- Allow corrections/additions
- Run the render script automatically:
~/.claude/skills/audit/scripts/render-puml.sh <audit-dir> - Mark phase as "complete"
Diagram Guidelines
Embedding in Markdown
Small diagrams can be embedded directly:
```plantuml @startuml Alice -> Bob: Hello Bob -> Alice: Hi @enduml ```
Separate Files
Larger diagrams go in
diagrams/:
- Reference in markdown:

Supported Types
/@startuml
- class, sequence, activity, component@enduml
/@startmindmap
- hierarchical views@endmindmap
/@startwbs
- work breakdown structures@endwbs
/@startjson
- data structure visualization@endjson
Valid Colors
PlantUML only supports specific color names. Use these valid colors:
| Category | Valid Colors |
|---|---|
| Basic | Red, Green, Blue, Yellow, Orange, Purple, Pink, Cyan, Magenta, White, Black, Gray |
| Light | LightBlue, LightGreen, LightYellow, LightGray, LightPink, LightCyan, LightCoral, LightSalmon |
| Purple variants | Lavender, Plum, Violet, Orchid, MediumPurple, DarkViolet, Indigo, Thistle |
| Other | Aqua, Beige, Coral, Crimson, Gold, Khaki, Lime, Maroon, Navy, Olive, Silver, Teal, Tomato |
Invalid colors to avoid: LightPurple, LightOrange, LightRed (use alternatives above)
You can also use hex codes:
#E6E6FA (lavender), #DDA0DD (plum), #EE82EE (violet)
Templates
Use templates from
templates/ directory for consistency:
- Main audit indextemplates/index.md
- Per-file component summarytemplates/component.md
- Cross-cutting concern documentationtemplates/aspect.md
- System entry points documentationtemplates/entry-points.md
- Technical debt trackingtemplates/techdebt.md
Render Script
The
scripts/render-puml.sh script:
- Uses Docker (
image)plantuml/plantuml - Converts
files to SVG.puml - Processes markdown files to replace plantuml blocks/references with SVG
- Outputs to
directorygenerated/
Usage:
~/.claude/skills/audit/scripts/render-puml.sh /path/to/audit