cli-audit-code
Skill0 starsChanged 3 months agoMITView on GitHub
Audit code quality with weighted scoring across 12 dimensions (naming, complexity, module design, DRY, errors, security, tests, architecture). Detects named anti-patterns (Fowler/Mantyla taxonomy). Use when reviewing code quality, auditing clean code compliance, checking for code smells, or saying 'audit code', 'code quality', 'code review', 'tech debt'. Invoke with an optional file or directory path.
- Reads credentials
1 other project uses a version of this, 1 of them edited.
Adopted by
Most recently taken up by
- Destynova2/cli-code-skillsedited, first seen Nov 8, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 1
- Destynova2/cli-code-skills★ 599% same
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository39 other files it gives its agents.
- .cursor/rules/cli-audit-code.mdcCursor rule
- .cursor/rules/cli-audit-doc.mdcCursor rule
- .cursor/rules/cli-forge-arch.mdcCursor rule
- .cursor/rules/cli-forge-schema.mdcCursor rule
- cli-audit-dataSkill
- cli-audit-docSkill
- cli-audit-driftSkill
- cli-audit-hanoiSkill
- cli-audit-reviewSkill
- cli-audit-shellSkill
- cli-audit-syncSkill
- cli-audit-tangleSkill
- cli-audit-testSkill
- cli-audit-wizardSkill
- cli-audit-xraySkill
- cli-cycleSkill
- cli-forge-archSkill
- cli-forge-chefSkill
- cli-forge-choice-uxSkill
- cli-forge-dataSkill
- cli-forge-demoSkill
- cli-forge-docSkill
- cli-forge-githubSkill
- cli-forge-hldSkill
- cli-forge-infraSkill
- cli-forge-lldSkill
- cli-forge-oci-rootlessSkill
- cli-forge-perfSkill
- cli-forge-pipelineSkill
- cli-forge-plumeSkill
- cli-forge-prezSkill
- cli-forge-profileSkill
- cli-forge-quorumSkill
- cli-forge-readmeSkill
- cli-forge-resilienceSkill
- cli-forge-schemaSkill
- cli-forge-treeSkill
- cli-git-conventionalSkill
- cli-watermarkSkill
The file
We split this skill into the rules it gives an agent
10 rules. About 0 are common, 5 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 32
If a specific file: audit that file deeply
- Distinctive: line 33
If a directory: audit all source files in it
- Very specific: line 34
If empty: audit src/ broadly (sample 15-20 key files)
- Distinctive: line 63
Do not read a large source file end-to-end as the first step.
- Very specific: line 66
When evidence points at a line, read a bounded slice around it: about 75 lines before and after, 150 lines max by default.
- Distinctive: line 67
Read a full file only when it is 300 lines or less, or when whole-file semantics are required.
- Very specific: line 69
Prefer RTK wrappers for noisy shell output when available: rtk git, rtk cargo, rtk grep, rtk find, and bounded rtk read.
- Very specific: line 77
Read references/categories.md for detailed checks.
- Very specific: line 81
Read references/scoring.md for the CQI formula, severity classification, named anti-patterns table, tech debt estimation, and comparative …
- Distinctive: line 149
After your analysis, recommend these skills if conditions are met:
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Optimization: This skill uses on-demand loading. Heavy content lives in
references/and is loaded only when needed.
Language rule: Skill instructions are written in English. When generating user-facing output, detect the project's primary language (from README, comments, docs, commit messages) and produce the report in that language. If the project is bilingual, ask the user which language to use before proceeding.
Audit Code — Code Quality Index (CQI)
"Complexity is the single greatest enemy of reliability." — John Ousterhout
Core Principles
- Evidence-based — every finding needs a
file:linereference. No vague "the code could be better" - Proportional — a 200-line function matters more than a missing doc comment. Scale to project type
- Language-aware — detect the project language and apply its idiomatic patterns, not Java/C# defaults
- Named anti-patterns — use Fowler/Mantyla taxonomy names (Feature Envy, Shotgun Surgery) in findings
- Positive reinforcement — always highlight good practices found, not just violations
- Gotchas — read
../gotchas.mdbefore producing output to avoid known mistakes
Input
$ARGUMENTS is the target to audit (file path, directory, or empty for whole src/).
- If a specific file: audit that file deeply
- If a directory: audit all source files in it
- If empty: audit
src/broadly (sample 15-20 key files)
12-Dimension Framework
Score each dimension 0.0-1.0, then compute a weighted CQI. Read references/categories.md for detailed check lists per category.
| # | Category | Weight | Key question |
| C1 | Naming & Readability | 8% | Do names reveal intent? No magic numbers? |
| C2 | Functions & Cognitive Complexity | 12% | < 30 lines? Cognitive complexity < 15? |
| C3 | Module Design (deep vs shallow) | 10% | Deep modules? No pass-through layers? |
| C4 | DRY & Change Amplification | 8% | One change = one file? No copy-paste? |
| C5 | Error Handling & Robustness | 10% | Errors propagated? No swallowed errors? |
| C6 | Type Safety & Language Idioms | 8% | Type system leveraged? Idiomatic patterns? |
| C7 | Comments & Public API Docs | 5% | Public API documented? No redundant comments? |
| C8 | Test Quality | 12% | Error paths tested? No flaky tests? |
| C9 | Security & Input Validation | 10% | Inputs validated at boundaries? No hardcoded secrets? |
| C10 | Immutability & State Management | 7% | Minimal mutable state? No global mutables? |
| C11 | Cognitive Load & Control Flow | 5% | < 3 nesting levels? No negative conditionals? |
| C12 | Dependencies & Architecture | 5% | No circular deps? DIP respected? |
Workflow
Step 1 — Discover and sample
Glob source files. For broad audit, prioritize: entry points, public API modules, most-changed files (git log), largest files.
Context Budget Rule
Do not read a large source file end-to-end as the first step.
- For files over 300 lines or directory audits, start with inventory only: file list, line counts, symbol or function index, git churn, and focused risk greps.
- When evidence points at a line, read a bounded slice around it: about 75 lines before and after, 150 lines max by default. Use
nl -ba path | sed -n 'START,ENDp',sed -n 'START,ENDp', orrtk read -n -m 150 pathwhen RTK is available. - Read a full file only when it is 300 lines or less, or when whole-file semantics are required. State that reason in the report.
- Reuse previously read slices and line references instead of re-reading the same file.
- Prefer RTK wrappers for noisy shell output when available:
rtk git,rtk cargo,rtk grep,rtk find, and boundedrtk read. Do not treat genericrtk logoutput as authoritative for structured JSON logs unless a domain-specific filter verifies it.
Step 2 — Detect language and context
Identify project language, framework, and type (library, CLI, service, script). This determines which idiom checks apply and what scoring standards are proportional.
Step 3 — Score all 12 dimensions
Read references/categories.md for detailed checks. For each category: collect evidence, assign score 0.0-1.0, note specific file:line findings.
Step 4 — Compute CQI and detect anti-patterns
Read references/scoring.md for the CQI formula, severity classification, named anti-patterns table, tech debt estimation, and comparative benchmarks.
CQI = Σ(wᵢ × sᵢ) / Σ(wᵢ) × 10Step 5 — Generate report
Finding tier and confidence semantics are canonical in ../shared/triage.md (Tier 3/2/1 + GRADE + triangulation). Emit each finding with its tier and confidence so cli-cycle can aggregate without re-parsing.
Output Format
# Code Quality Audit — {project-name}
**Target**: [file/directory] | **Language**: [detected] | **Date**: [date]
**CQI Score**: X.X/10 — {verdict} | **Tech Debt**: ~Xh ({SQALE grade})
## Scores by Category
| # | Category | Weight | Score | Weighted | Findings |
|---|----------|--------|-------|----------|----------|
| C1-C12 rows with 0.0-1.0 scores... |
| | **CQI** | **100%** | | **X.X/10** | |
## Anti-Patterns Detected
| Pattern | Severity | File:Line | Recommendation |
## Critical Violations (must fix)
### [Category]: [violation title]
- **File**: `path/to/file:123`
- **What**: [description]
- **Why**: [named principle/smell it violates]
- **Fix**: [concrete suggestion]
- **Disproof**: [observation that would invalidate this finding — e.g., "this isn't dead code IF dynamic dispatch is used here"]
## Flags (should fix)
[same format]
## Good Practices Found
[positive reinforcement]
## Recommended Next Steps
1. [highest-impact fix first]
2. [second]
3. [third]What this skill does NOT do
- Does not fix code — it reports. Use the findings to guide refactoring
- Does not replace linters — it complements them with semantic analysis a linter can't do
- Does not check test coverage numbers — it checks test quality. Use
cli-audit-testfor test strategy - Does not audit documentation quality — use
cli-audit-docfor that
Integration with other cli-* skills
| Skill | Relationship |
cli-audit-xray | Turns static hidden-cost smells (repeated work, clones, allocations, bad cache placement) into optimization cards with invariants and validation |
cli-audit-doc | Scores doc quality. cli-audit-code scores code quality |
cli-audit-test | Scores test strategy. cli-audit-code checks test code quality (C8) |
cli-forge-lld | Validates implementation matches the LLD design |
cli-forge-perf | Detects static perf anti-patterns (alloc in hot path, quadratic complexity, hidden-cost abstractions). cli-forge-perf verifies they are dynamically costly via profiling + bench |
cli-cycle | Calls cli-audit-code as part of full project review; emit .agents/cli-audit-code.json per ../shared/result-schema.md for orchestrator aggregation |
Dynamic Handoffs
After your analysis, recommend these skills if conditions are met:
| Condition detected | Recommend | Why |
| Repeated computation, allocation/copy churn, cache-before-normalization, or dataflow cost with unclear safety | /cli-audit-xray | Build semantic/resource-flow candidates before recommending a rewrite |
| God class/module (C3 > 500 lines, many responsibilities) | /cli-audit-tangle | Topology analysis reveals optimal split points |
Hardcoded secrets or .env tracked in git (C9) | /cli-git-conventional --audit-markers | Check git history for leaked secrets |
| Shell scripts in the project with quality issues | /cli-audit-shell | Deep bash-specific audit beyond C6 idioms |
| Missing or stale documentation (C7 low) | /cli-forge-doc | Generate/update project docs |
| Test quality issues (C8 low) | /cli-audit-test | Full test strategy audit |
| CI/CD config present but not audited | /cli-forge-pipeline | Pipeline optimization |
| Static perf anti-pattern detected (alloc in loop, O(n²), N+1) on a hot service | /cli-forge-perf | Confirm the dynamic cost and lock the fix with an A/B bench gate |
| PostgreSQL/SQLx flow has read-before-write, split transactions, ignored zero-row writes, or tenant-key gaps | /cli-audit-data | Prove database invariants and concurrent executions |
Rule: Recommend, don't auto-execute. Phrase as: "Consider running /cli-audit-tangle — 3 god modules detected that need topology analysis."
Reference Sources
- Ousterhout — A Philosophy of Software Design | Martin — Clean Code | Fowler — Refactoring | Tornhill — Software Design X-Rays | Feathers — Working Effectively with Legacy Code
- SonarQube Quality Model | SonarSource Cognitive Complexity | SQALE Method | CodeScene Code Health | Clippy lint categories
- CodeAesthetic | ThePrimeagen | ArjanCodes | Software Engineering Radio | Tech Lead Journal
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

