code-simplification
Skill66 starsChanged 5 months agoMITView on GitHub
Finds and removes duplication, dead code, over-engineering, and AI-generated bloat such as verbose error handling and redundant type checks. Use after implementing features, before claiming a phase is complete, when reviewing AI-generated code, or when code feels overly complex. Also use when a pattern repeats across files, a function exceeds 40 lines, nesting exceeds 3 levels, or an abstraction has only one implementation.
83 other projects use a version of this.
Adopted by
Most recently taken up by
- ishandutta2007/Awesome-Agent-Skillstheir own version, first seen Nov 8, 2026
- dmoreq/agent-grimoiretheir own version, first seen Nov 8, 2026
- Mehul72/skillstheir own version, first seen Nov 8, 2026
- Anish59312/skillstheir own version, first seen Nov 8, 2026
- MMACABRE/SKILLStheir own version, first seen Nov 8, 2026
- gopalparashar421/agent-skillstheir own version, first seen Nov 8, 2026
Used with
Projects with it also use constraint-driven-development, incremental-implementation and 9 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
MrCipherSmithSkillconstraint-driven-development
Use when a project needs a persistent, measurable quality bar — starting a project without documented standards, 'set up constraints', or when coverage/perf/a11y thresholds get re-debated per-PR. Produces CONSTRAINTS.md with enforceable numbers, ratchets, and a guard against silent weakening. NOT for throwaway prototypes or a one-off CI setup.
Also in 16 projects that use this
LLl0k0laDSkillincremental-implementation
Use when implementing any feature or change that touches more than one file. Use when you're about to write a large amount of code at once, or when a task feels too big to land in one step.
Also in 44 projects that use this
barisariburnuSkillperformance-optimization
Complete performance optimization guide for Next.js applications including frontend, backend, database, caching, and general optimization strategies. Use when improving performance, reducing bundle size, optimizing queries, or implementing caching.
Also in 47 projects that use this
GSA-TTSSkillarchitecture-decision-records
Load when a user wants architecture decision records (ADRs) drafted from requirements or a design discussion, asks which decisions need an ADR, or wants an ADR draft reviewed for one-sided trade-offs, weak alternatives or missing requirement links. Not for setting up a project's whole documentation system (project-documentation-system).
Also in 4 projects that use this
JohnJBorenSkillci-cd
CI/CD pipeline design, GitHub Actions, testing automation, and deployment strategies
Also in 3 projects that use this
OpenAISkillsecurity-best-practices
Perform language and framework specific security best-practice reviews and suggest improvements. Trigger only when the user explicitly requests security best practices guidance, a security review/report, or secure-by-default coding help. Trigger only for supported languages (python, javascript/typescript, go). Do not trigger for general code review, debugging, or non-security tasks.
Also in 3 projects that use this
Other versions83 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 83
- addyosmani/agent-skills★ 114ksame name
- sanity-io/sanity★ 6.4ksame name
- luxury-yacht/app★ 446same name
- shashankswe2020-ux/whoop-mcp★ 174same name
- sammcj/agentic-coding★ 169same name
- HybridAIOne/hybridclaw★ 159same name
- muratgur/ordinus★ 111same name
- tranhieutt/software_development_department★ 71same name
- c-kick/hnl-agent-skills★ 56same name
- vinvcn/addyosmani-agent-skills-zh★ 46same name
73 more not listed
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 repository20 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- documentationSkill
- git-workflowSkill
- import-spec-fileSkill
- import-specSkill
- infrastructure-validationSkill
- lessons-learnedSkill
- parallel-dispatchSkill
- security-auditSkill
- shipyard-brainstormingSkill
- shipyard-debuggingSkill
- shipyard-executing-plansSkill
- shipyard-handoffSkill
- shipyard-tddSkill
- shipyard-testingSkill
- shipyard-verificationSkill
- shipyard-writing-plansSkill
- shipyard-writing-skillsSkill
- using-shipyardSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
15 rules. 0 are common, 15 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 77 edited versions we read keep these.
15
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 14
After all tasks in a phase are complete (before shipping)
- Distinctive: line 15
When reviewing code generated by multiple builder agents
- Distinctive: line 16
When a file has been touched by 3+ different tasks
- Distinctive: line 17
When you notice patterns repeating across files
- Distinctive: line 18
Before claiming a phase is production-ready
- Distinctive: line 33
This skill applies after implementation, not during: Don't prematurely optimize -- but don't ship bloat either.
- Distinctive: line 39
When reviewing code for simplification:
- Distinctive: line 42
Scan for duplication: Look for similar patterns across files
- Distinctive: line 44
Find dead code: Look for unused definitions
- Distinctive: line 45
Spot over-engineering: Look for abstractions with single implementations
- Distinctive: line 86
Parallel hierarchies: When adding a new type requires changes in multiple places.
- Distinctive: line 100
Extract method: When a function does too many things.
- Distinctive: line 143
Replace conditionals with polymorphism: When type-checking drives behavior.
- Distinctive: line 171
Test utilities -- called only from tests
- Distinctive: line 192
Rule: If there's only one implementation, don't create an abstraction.
“Common” is measured: kept by at least 6 in 10 of the 77 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
<!-- TOKEN BUDGET: 400 lines / ~1200 tokens -->Code Simplification
<activation>When This Skill Activates
- After all tasks in a phase are complete (before shipping)
- When reviewing code generated by multiple builder agents
- When a file has been touched by 3+ different tasks
- When you notice patterns repeating across files
- Before claiming a phase is production-ready
The simplifier agent references this skill for systematic cross-task analysis.
Natural Language Triggers
- "simplify this", "clean up", "too complex", "reduce complexity", "this is bloated"
</activation>Overview
AI-generated code accumulates complexity. Each task is implemented in isolation by a fresh agent that can't see the full picture. After multiple tasks, duplication creeps in, abstractions multiply, and dead code lingers.
Core principle: The simplest code that works correctly is the best code. Complexity is a cost, not a feature.
This skill applies after implementation, not during. Don't prematurely optimize -- but don't ship bloat either.
<instructions>Simplification Process
When reviewing code for simplification:
- Identify scope: What files changed in this phase? (Use git diff)
- Scan for duplication: Look for similar patterns across files
- Check complexity: Flag functions exceeding thresholds
- Find dead code: Look for unused definitions
- Spot over-engineering: Look for abstractions with single implementations
- Check AI patterns: Apply the AI anti-pattern checklist
- Prioritize findings:
- High: Clear duplication (3+), dead code, obvious bloat
- Medium: Complexity reduction, near-duplicates
- Low: Style consistency, minor simplifications
Duplication Detection
What to Look For
Exact duplicates: Identical code blocks in different files or functions.
# RED FLAG: Same logic in two places
def validate_user_email(email):
if not email or "@" not in email:
raise ValueError("Invalid email")
def validate_contact_email(email):
if not email or "@" not in email:
raise ValueError("Invalid email")Near duplicates: Same structure, different details.
# RED FLAG: Parallel structure, only names differ
def create_user(data):
validate(data)
user = User(**data)
db.add(user)
db.commit()
return user
def create_project(data):
validate(data)
project = Project(**data)
db.add(project)
db.commit()
return projectParallel hierarchies: When adding a new type requires changes in multiple places.
Copy-paste config: Same configuration blocks repeated in Docker, Terraform, or CI files.
The Rule of Three
- 2 occurrences: Note it, but don't extract yet.
- 3 occurrences: Extract. The pattern is real.
- 1 abstraction serving 1 caller: Inline it. The abstraction has no value.
Complexity Reduction
Techniques
Extract method: When a function does too many things.
# BEFORE: One function doing everything
def process_order(order):
# validate (10 lines)
# calculate totals (15 lines)
# apply discounts (12 lines)
# save to database (8 lines)
# send notification (6 lines)
# AFTER: Clear responsibilities
def process_order(order):
validate_order(order)
totals = calculate_totals(order)
totals = apply_discounts(totals, order.customer)
save_order(order, totals)
notify_order_placed(order)Early returns / guard clauses: Eliminate deep nesting.
# BEFORE: Nested conditionals
def get_discount(user):
if user:
if user.is_premium:
if user.years > 5:
return 0.20
else:
return 0.10
else:
return 0.0
else:
return 0.0
# AFTER: Guard clauses
def get_discount(user):
if not user or not user.is_premium:
return 0.0
if user.years > 5:
return 0.20
return 0.10Replace conditionals with polymorphism: When type-checking drives behavior.
Simplify boolean expressions: Collapse nested boolean logic.
Complexity Thresholds
| Metric | Acceptable | Review | Refactor |
| Function length | < 20 lines | 20-40 lines | > 40 lines |
| Nesting depth | <= 2 levels | 3 levels | > 3 levels |
| Parameters | <= 3 | 4-5 | > 5 |
| Cyclomatic complexity | <= 5 | 6-10 | > 10 |
Dead Code Identification
What Counts as Dead Code
- Unused imports -- imported but never referenced
- Unused variables -- assigned but never read
- Unreachable branches -- conditions that can never be true
- Commented-out code -- if it's needed, it's in git history
- Unused functions/methods -- defined but never called
- Vestigial parameters -- accepted but never used
- Feature flags for shipped features -- the flag is always on
What Does NOT Count
- Public API surface -- may have external callers
- Test utilities -- called only from tests
- Interface implementations -- required by contract
- Error handlers for rare conditions -- needed for robustness
Over-Engineering Indicators
Premature Abstraction
# OVER-ENGINEERED: Abstract factory for one implementation
class NotificationFactory:
@staticmethod
def create(type):
if type == "email":
return EmailNotifier()
raise ValueError(f"Unknown: {type}")
# SIMPLE: Just use the thing directly
notifier = EmailNotifier()Rule: If there's only one implementation, don't create an abstraction. Add it when the second implementation arrives.
Unnecessary Indirection
# OVER-ENGINEERED: Service wrapping a service
class UserService:
def get_user(self, id):
return self.repository.get_user(id) # Just passes through
# SIMPLE: Use the repository directly where needed
user = repository.get_user(id)Configuration for One Value
# OVER-ENGINEERED
MAX_RETRIES = config.get("max_retries", 3)
# SIMPLE (if this is the only place retries happen)
MAX_RETRIES = 3Rule: Make it configurable when a second consumer needs a different value, not before.
AI-Specific Anti-Patterns
AI code generators commonly produce these patterns. Watch for them:
Verbose Error Handling
# AI BLOAT: Every function has identical error handling
def get_user(id):
try:
user = db.query(User).get(id)
if user is None:
raise ValueError(f"User {id} not found")
return user
except ValueError:
raise
except Exception as e:
logger.error(f"Error getting user: {e}")
raise RuntimeError(f"Failed to get user {id}") from e
# SIMPLER: Let exceptions propagate naturally
def get_user(id):
user = db.query(User).get(id)
if user is None:
raise ValueError(f"User {id} not found")
return userRedundant Type Checks
# AI BLOAT: Checking types that can't be wrong
def process(items: list[str]) -> None:
if not isinstance(items, list):
raise TypeError("Expected list")
for item in items:
if not isinstance(item, str):
raise TypeError("Expected str")
# actual logic...
# SIMPLER: Trust the type system
def process(items: list[str]) -> None:
for item in items:
# actual logic...Over-Defensive Coding
# AI BLOAT: Null checks where nulls can't happen
user = get_authenticated_user() # Already validated by middleware
if user is not None and user.id is not None: # Impossible to be None
process(user)
# SIMPLER: Trust your system boundaries
user = get_authenticated_user()
process(user)Unnecessary Wrapper Functions
# AI BLOAT: Wrapping standard library
def read_json_file(path):
with open(path) as f:
return json.load(f)
# Used exactly once -- just inline it
with open(config_path) as f:
config = json.load(f)Shell/Bash AI Anti-Patterns
# AI BLOAT: Excessive logging in every function
my_function() {
log_info "Entering my_function with args: $*"
log_debug "Checking if file exists: $1"
if [ -f "$1" ]; then
log_info "File found: $1"
cat "$1"
log_info "Exiting my_function successfully"
else
log_error "File not found: $1"
return 1
fi
}
# SIMPLER: Let set -e and meaningful exit codes do the work
my_function() {
cat "$1"
}# AI BLOAT: Wrapping simple commands in functions used once
get_current_branch() { git rev-parse --abbrev-ref HEAD; }
get_repo_root() { git rev-parse --show-toplevel; }
# SIMPLER: Inline when used once
branch=$(git rev-parse --abbrev-ref HEAD)# AI BLOAT: Redundant existence checks
if [ -n "${MY_VAR:-}" ]; then
if [ "${MY_VAR}" != "" ]; then # Redundant -- -n already checks this
process "$MY_VAR"
fi
fi
# SIMPLER: One check is enough
if [ -n "${MY_VAR:-}" ]; then
process "$MY_VAR"
fi</instructions><examples>Example: Full Simplification Finding
<example type="good" title="Identifying and resolving cross-agent duplication">
**Context:** Three builder agents each implemented a task touching API endpoints. Each added its own request validation helper.Finding: Three near-identical validate_request_body() functions in routes/users.py, routes/projects.py, and routes/teams.py.
Before (in each file):
def validate_request_body(body, required_fields):
if not body:
raise HTTPError(400, "Request body required")
for field in required_fields:
if field not in body:
raise HTTPError(400, f"Missing field: {field}")After (extracted to shared module):
# validators/request.py
def validate_request_body(body, required_fields):
if not body:
raise HTTPError(400, "Request body required")
for field in required_fields:
if field not in body:
raise HTTPError(400, f"Missing field: {field}")
# Each route file now imports:
from validators.request import validate_request_bodyPriority: High -- 3 exact duplicates, Rule of Three applies.
</example>
</examples><rules>Red Flags -- STOP and Simplify
- Same logic in 3+ places
- Function > 40 lines
- Nesting > 3 levels
- Abstract class with one concrete implementation
- Wrapper that just delegates
- Config for a value used in one place
- Try/except that re-raises the same exception
- Type check for a statically typed parameter
- Null check after a function that can't return null
- Commented-out code blocks
Common Rationalizations
| Excuse | Reality |
| "We might need it later" | YAGNI. Add it when you need it. |
| "It's more extensible" | Extensibility without use cases is waste. |
| "The abstraction makes it cleaner" | One caller = inline is cleaner. |
| "Deleting code feels risky" | Git remembers. Dead code is maintenance cost. |
| "It's just a few extra lines" | Lines compound. 10 files x 5 extra lines = 50 lines of noise. |
| "The AI generated it, it must be right" | AI optimizes for completeness, not simplicity. |
| "Refactoring might break things" | Tests exist. If they don't, add them first. |
</rules>Integration
Referenced by:
- shipyard:simplifier -- Uses this skill as the analysis framework for cross-task simplification
- shipyard:reviewer -- Code quality review (Stage 2) checks for complexity
Pairs with:
- shipyard:shipyard-tdd -- Tests make simplification safe
- shipyard:shipyard-verification -- Simplification claims need evidence
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.

