empiricaai/empirica/code-audit
Claude Code and agent skill by empiricaai/empirica
- community
Checking that the SKILL.md file is still in the repository.
Use when the user says '/code-audit', 'audit this code', 'check code quality', 'find duplication', 'find dead code', 'code cleanup', 'technical debt audit', 'code review module', or wants a structured noetic investigation of code quality. This skill runs external analysis tools and structured manual review, producing Empirica artifacts (findings, goals, decisions) that any praxic agent can execute.
Install
npx vskill@latest install empiricaai/empirica/code-auditSKILL.md
Code Audit: Noetic Investigation Skill
Investigate code quality. Produce structured remediation plans.
This skill is purely noetic — it discovers, triages, and plans. It does NOT make changes. The output (findings, goals, decisions) feeds directly into the Empirica workflow for any praxic agent to pick up and execute.
How to Run
Phase 1: Scope
Determine what to audit. If the user specified a target, use it. Otherwise, audit the current project root.
Log the audit scope:
Phase 2: Automated Tool Passes
Run external tools and parse results into findings. Each tool covers a different dimension. Skip any tool that isn't installed — the audit still works without it.
2a. Linting & Style (ruff)
Parse results:
- Group by rule category (import order, unused imports, complexity, etc.)
- Log aggregates as findings, not individual violations
- Impact scoring: unused imports = 0.2, complexity violations = 0.5, security = 0.8
2b. Dead Code (vulture)
Parse results:
- Filter out false positives (dynamically called functions, CLI entry points)
- Log confirmed dead code as findings
- Log uncertain cases as unknowns
2c. Complexity Metrics (radon)
Parse results:
- Functions rated C (11-20) → finding with impact 0.4
- Functions rated D (21-30) → finding with impact 0.6
- Functions rated F (31+) → finding with impact 0.8
- Log the worst offenders by name and file
2d. Test Freshness (scripts/test_freshness_audit.py)
Not a coverage check. Coverage asks "was this line executed?"; this asks "could this test have failed?" Tests drift like any other artifact, and a drifted test doesn't go red — it goes green over the wrong contract and guards the defect.
| finding | what it means | |
|---|---|---|
stale-fixture | a hand-built CREATE TABLE missing lifecycle columns the real schema has — fixture and code agree with each other and disagree with production | |
unfalsifiable-test | no assertion; passes unless something raises | |
tautological-assert | assert True / assert x == x — cannot fail by construction | |
frozen-over-churn | informational only — module changed repeatedly, its test didn't. Often correct (a contract test surviving refactors is doing its job); a prompt to look, never a defect |
Triage, don't bulk-fix. A minimal fixture is a legitimate choice; what makes it a finding is that the missing columns arrived in a migration after it was written. Log real ones as findings, and record deliberate omissions so the next sweep stays quiet on them.
2e. Type Errors (pyright)
Parse results:
- Count errors by category (missing types, incompatible types, possibly unbound)
- Log aggregates, not individual errors
Phase 3: Structural Review (Manual)
These dimensions require AI judgment — tools can't catch them.
3a. File Size Analysis
Thresholds:
- \>2000 LOC → finding with impact 0.5 ("needs splitting")
- \>1000 LOC → finding with impact 0.3 ("consider splitting")
- \>500 LOC → note only
3b. Duplication Detection
Search for functions defined in multiple places:
For each duplicate: Read both copies. Assess whether they're identical, similar, or intentionally different. Log accordingly:
3c. Module Boundary Assessment
Read the import graph. Check for:
- Circular imports — A imports B, B imports A
- Layer violations — CLI importing from data, data importing from core
- God modules — single file that everything imports
3d. Naming & Convention Consistency
Spot check:
- Mixed naming styles (snake_case vs camelCase)
- Inconsistent patterns (some files use
handle_X_command, others useX_handler) - Magic strings/numbers without constants
3e. Error Handling — success-shaped nothing
The count of except: pass is the least of it. The defect that survives lint, types, coverage and a green suite is a failure that returns the value meaning "measured" or "done": return 0 on a COUNT that raised, return [] on a timeout, passed=True on a skipped check, a stub rendering constants as a grade, a verb printing ✅ then ❌ and exiting 0. Lesson b329fdbb1d6ddacb (org pool, lesson-create --from-global) carries the five shapes and a worked day; the probe is:
Then run each verb live and read exit code against banner. A parser, a doc page and a passing test do not prove a verb works — investigate had all three and zero working paths for its whole life.
When the defect survived a green suite, the test is a suspect. A test that asserts the defective surface (returncode == 0 on the stub) is green exactly where it is blind — rewrite it to the contract and let it go red first.
3f. Matchers — over a formal grammar, or over natural language?
Any check keyed on words or phrases rather than on a grammar. Word lists, antonym or negation sets, risk-word scans, TODO-alikes, "does this text say X" predicates.
The discriminator is FORMAL vs NATURAL, not keyword-matching-good-or-bad. Both are legitimate shapes and both ship in the same repos:
| ✅ formal | ❌ natural | ||
|---|---|---|---|
| grammar | fixed, published (SQL, an AST, an enum, a config schema) | emergent, contested | |
| a token's denotation | fixed — SELECT is always SELECT | context-dependent, drifts | |
| a miss is | a parser bug — findable, fixable | invisible, and reads as a result |
The tell: can I enumerate the tokens and be done? Over a published grammar the spec is finite. Over natural language it never is, and an unfinishable list produces false negatives by construction — so zero hits reads as "nothing to find" when it means "cannot see".
For each: what is it matching against? Source code, config, or a wire format → formal, fine. Prose a human or a model wrote → the finding below.
Before condemning one, measure it. Run the predicate over the real corpus it sees, exhaustively where the gate makes that possible, with a positive control proving the instrument is live. A measured zero beats an argument from principle, and it is the difference between "I don't like this" and a finding.
The counter-move is not a longer list. Prefer a signal the system already produces from behaviour — a verdict, a test result, an observed outcome — over one that must be inferred by reading text.
Phase 4: Triage
Review all findings. Assign categories and prioritize.
Categories:
| Tag | Meaning | |
|---|---|---|
duplication | Same code in multiple places | |
complexity | Function/file too complex or too large | |
dead-code | Unused code that should be removed | |
consistency | Naming, patterns, conventions don't match | |
architecture | Module boundaries, layering, coupling | |
reliability | Error handling, edge cases, silent failures | |
security | Input validation, injection risks |
Impact scoring guide:
| Score | Meaning | |
|---|---|---|
| 0.1-0.3 | Cosmetic — style, minor inconsistency | |
| 0.4-0.6 | Structural — duplication, complexity, dead code | |
| 0.7-0.9 | Critical — bug source, security risk, architecture violation |
Phase 5: Create Remediation Goals
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingempirica/plugins/claude-code-integration/skills/code-audit/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/empiricaai/empirica/code-audit)