hygiene-audit
Skill3 starsChanged 8 months agoApache-2.0View on GitHub
Run a comprehensive codebase hygiene audit. Spawns a team of recon and research agents to analyze structure, dependencies, inconsistencies, and industry best practices, then synthesizes findings into an actionable refactoring plan with phased implementation.
In this repository21 other files it gives its agents.
- framework/CLAUDE.mdCLAUDE.md
- auditSkill
- dep-auditSkill
- review-prSkill
- api-conventionsSkill
- dashboard-conventionsSkill
- db-migrationSkill
- doc-architectureSkill
- fix-issueSkill
- new-endpointSkill
- new-mcp-toolSkill
- test-allSkill
- deploySkill
- deploy-statusSkill
- incidentSkill
- dreamSkill
- brainstormSkill
- debateSkill
- exec-planSkill
- launch-reviewSkill
- plan-featuresSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
30 rules. About 0 are common, 25 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈25
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 10
Run a full codebase hygiene audit.
- Very specific: line 14
Create a team using TeamCreate with a team lead and the following agents.
- Very specific: line 31
Check for proper __init__.py exports vs star imports
- Distinctive: line 32
Verify the one-file-per-module convention
- Distinctive: line 33
Check test file organization mirrors source file organization
- Distinctive: line 34
Look for orphaned files (source files with no corresponding test, or vice versa)
- Distinctive: line 68
Check for layering violations (lower-level modules importing from higher-level ones)
- Distinctive: line 70
Check for vendored or duplicated utility code that should be shared
- Distinctive: line 112
Check for inconsistent error handling patterns across the codebase
- Distinctive: line 114
Check for inconsistent naming conventions (snake_case vs camelCase, abbreviations)
- Distinctive: line 115
Verify datetime handling conventions (UTC internally, convert for display)
- Distinctive: line 116
Check for sync I/O in async code paths (blocking calls in async functions)
- Distinctive: line 118
Check for inconsistent use of logging (structured logging vs print statements)
- Distinctive: line 119
Verify typed models used for all shared data structures (not raw dicts)
- Distinctive: line 120
Check for hardcoded values that should be configuration
- Very specific: line 121
Look for TODO/FIXME/HACK/XXX comments and categorize them
- Distinctive: line 165
Search for module splitting patterns and project structure best practices for the project's framework
- Distinctive: line 166
Look at how popular open-source projects organize similar code
- Distinctive: line 192
Search for project structure best practices for the frameworks in use
- Distinctive: line 193
Search for common pitfalls in projects at this stage (pre-launch, growing feature set)
- Distinctive: line 273
If the user wants to proceed with fixes after reviewing the audit, spawn implementation teams per phase.
- Very specific: line 282
Create a feature branch: refactor/hygiene-phase-X-[description]
- Distinctive: line 285
Run QA pipeline (lint + types + tests)
- Distinctive: line 286
If QA fails, fix issues and re-run
- Distinctive: line 291
Only the team lead spawns agents (never delegate spawning to sub-agents)
- Distinctive: line 294
If a phase has independent sub-tasks, parallelize them
- Very specific: line 298
If $ARGUMENTS specifies a focus area, limit the audit scope:
- Distinctive: line 299
structure: Only run Agent 1 (Structure & Size) and Agent 4 (Splitting Patterns)
- Distinctive: line 300
dependencies: Only run Agent 2 (Dependency & Coupling)
- Distinctive: line 301
duplication: Only run Agent 3 (Inconsistency & Duplication)
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 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
Codebase Hygiene Audit
Run a full codebase hygiene audit. This skill coordinates a team of agents to analyze the codebase from multiple angles and produce an actionable refactoring plan.
Phase 1: Reconnaissance (Parallel Agents)
Create a team using TeamCreate with a team lead and the following agents. All recon agents run in parallel.
Team Structure
Team name: hygiene-audit
Team lead task: Coordinate recon agents, collect reports, synthesize findings, present recommendations.
Agent 1: Structure & Size Recon
Name: structure-recon
Task:
Analyze the codebase structure, file sizes, and module organization.
- Map the full directory tree of source and test directories with file counts per directory
- Identify files over 300 lines -- these are candidates for splitting
- Identify files over 500 lines -- these are urgent split candidates
- Count classes and functions per file to find "god files"
- Check for proper
__init__.pyexports vs star imports - Verify the one-file-per-module convention
- Check test file organization mirrors source file organization
- Look for orphaned files (source files with no corresponding test, or vice versa)
Output format:
## Structure & Size Report
### File Size Distribution
- Files > 500 lines: [list with line counts]
- Files > 300 lines: [list with line counts]
- Files > 200 lines: [list with line counts]
### God Files (5+ classes or 10+ functions)
[list with counts]
### Module Organization Issues
[list of violations]
### Orphaned Files (no matching test or source)
[list]
### Directory Tree Summary
[tree with file counts]Agent 2: Dependency & Coupling Recon
Name: dependency-recon
Task:
Analyze import graphs, coupling between modules, and dependency health.
- Map internal imports between subpackages
- Identify circular imports or circular dependency chains
- Find modules with high fan-in (many importers -- fragile to change)
- Find modules with high fan-out (imports many things -- too many responsibilities)
- Check for layering violations (lower-level modules importing from higher-level ones)
- Audit package manager config for unused or missing dependencies
- Check for vendored or duplicated utility code that should be shared
- Identify tightly coupled module pairs (always imported together)
Expected layering (customize for your project -- lower layers should NOT import from higher layers):
core (lowest) -> plugins -> api/cli (highest)
-> db (sideways, used by all)Output format:
## Dependency & Coupling Report
### Import Graph Summary
- Total internal imports: N
- Cross-package imports: N
### Layering Violations
[list with file:line references]
### High Fan-In Modules (imported by 5+ files)
[list with importer counts]
### High Fan-Out Modules (imports 5+ internal modules)
[list with import counts]
### Circular Dependencies
[list or "None found"]
### Unused/Missing Dependencies
[list or "All clean"]
### Tightly Coupled Pairs
[list of module pairs that are always co-imported]Agent 3: Inconsistency & Duplication Recon
Name: inconsistency-recon
Task:
Find code inconsistencies, duplicated logic, and convention violations.
- Check for inconsistent error handling patterns across the codebase
- Find duplicated logic (same or very similar code in multiple places)
- Check for inconsistent naming conventions (snake_case vs camelCase, abbreviations)
- Verify datetime handling conventions (UTC internally, convert for display)
- Check for sync I/O in async code paths (blocking calls in async functions)
- Find bare
except:or overly broadexcept Exception:catches - Check for inconsistent use of logging (structured logging vs print statements)
- Verify typed models used for all shared data structures (not raw dicts)
- Check for hardcoded values that should be configuration
- Look for TODO/FIXME/HACK/XXX comments and categorize them
Output format:
## Inconsistency & Duplication Report
### Duplicated Logic
[list with file pairs and description]
### Convention Violations
- Datetime: [issues]
- Error handling: [issues]
- Naming: [issues]
- Sync I/O in async: [issues]
- Logging: [issues]
### Bare/Broad Exception Catches
[list with file:line]
### Raw Dicts Instead of Models
[list with file:line]
### Hardcoded Values
[list with suggested config extraction]
### TODO/FIXME/HACK Comments
[categorized list with file:line]Phase 2: Research (Parallel Agents, Web Search)
These agents run in parallel with each other, but AFTER Phase 1 completes (they need the recon findings as context).
Agent 4: Splitting Patterns Research
Name: splitting-research
Task:
Research best practices for splitting the specific types of large files found in Phase 1.
- Web search for best practices on splitting modules that match the patterns found:
- API route files with many endpoints
- Large test files
- Plugin files with multiple responsibilities
- Core engine files with mixed concerns
- Search for module splitting patterns and project structure best practices for the project's framework
- Look at how popular open-source projects organize similar code
- Recommend specific splitting strategies for each large file identified in Phase 1
Output format:
## Splitting Patterns Research
### Best Practices Found
[summary of research with source links]
### Recommended Splits
For each large file from Phase 1:
- File: [path]
- Current size: [lines]
- Recommended split: [description]
- New file structure: [list of new files]
- Migration risk: low/medium/highAgent 5: Project Optimization Research
Name: optimization-research
Task:
Research optimization patterns specific to projects of this type.
- Web search for architecture patterns relevant to the project's domain
- Search for project structure best practices for the frameworks in use
- Search for common pitfalls in projects at this stage (pre-launch, growing feature set)
- Research testing patterns for the project's domain
- Identify architectural smells common in projects at this growth stage
Output format:
## Project Optimization Research
### Architecture Patterns
[relevant patterns with applicability assessment]
### Common Pitfalls at This Stage
[list of anti-patterns to watch for]
### Recommended Optimizations
[prioritized list with effort/impact ratings]
### Testing Improvements
[specific to the project's domain and testing framework]Phase 3: Synthesis (Team Lead)
The team lead collects all 5 reports and produces the final audit document.
Synthesis Format
# Codebase Hygiene Audit
**Date**: [current date]
**Scope**: [all or focus-area from $ARGUMENTS]
## Executive Summary
[2-3 sentence overview of codebase health with a letter grade A-F]
## Critical Issues (Fix Now)
[Issues that block scaling or cause bugs -- from all recon reports]
## High Priority (Fix This Sprint)
[Issues that slow development or create tech debt]
## Medium Priority (Fix This Month)
[Issues that are annoying but not blocking]
## Low Priority (Backlog)
[Nice-to-haves and minor inconsistencies]
## Refactoring Plan
### Phase A: Quick Wins (< 1 hour each)
[Small fixes that improve quality immediately]
- [ ] Fix 1: [description] -- [file path]
- [ ] Fix 2: [description] -- [file path]
### Phase B: Module Splits (1-3 hours each)
[Large file splits with specific plans]
- [ ] Split 1: [file] into [new files] -- [strategy]
- [ ] Split 2: [file] into [new files] -- [strategy]
### Phase C: Architecture Improvements (half-day each)
[Structural changes to layering, dependency management, etc.]
- [ ] Improvement 1: [description]
- [ ] Improvement 2: [description]
### Phase D: Convention Alignment (ongoing)
[Gradual fixes to inconsistencies, can be done opportunistically]
- [ ] Convention 1: [description]
- [ ] Convention 2: [description]
## Metrics to Track
- Total lines of code: [N]
- Largest file: [path] ([N] lines)
- Average file size: [N] lines
- Test coverage estimate: [N]%
- Convention violation count: [N]Phase 4: Implementation (Optional)
If the user wants to proceed with fixes after reviewing the audit, spawn implementation teams per phase. Each implementation team gets:
- An implementation agent (worktree isolation) that makes the changes
- A QA agent that runs the project's test suite and linter after changes
Implementation Team Pattern
For each phase (A, B, C, D), when the user approves:
- Create a feature branch:
refactor/hygiene-phase-X-[description] - Spawn implementation agent with worktree isolation
- Make changes according to the audit plan
- Run QA pipeline (lint + types + tests)
- If QA fails, fix issues and re-run
- Report results to team lead
- Team lead creates PR with the audit findings as context
Agent Spawning Rules
- Only the team lead spawns agents (never delegate spawning to sub-agents)
- Implementation agents use
isolation: "worktree"to avoid conflicts - QA agents validate after each change, not just at the end
- If a phase has independent sub-tasks, parallelize them
Scope Filtering
If $ARGUMENTS specifies a focus area, limit the audit scope:
- structure: Only run Agent 1 (Structure & Size) and Agent 4 (Splitting Patterns)
- dependencies: Only run Agent 2 (Dependency & Coupling)
- duplication: Only run Agent 3 (Inconsistency & Duplication)
- all (default): Run all 5 agents
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.

