code-simplification
Skill66 starsChanged 5 months agoMITView on GitHub
Use after implementing features, before claiming a phase is complete, when reviewing AI-generated code, or when code feels overly complex. Also use when you notice repeated patterns across files, a function exceeds 40 lines, nesting exceeds 3 levels, or an abstraction has only one implementation. Covers duplication, dead code, over-engineering, and AI-specific bloat patterns like verbose error handling and redundant type checks.
46 other projects use a version of this.
Adopted by
Most recently taken up by
- GuillemRoca/agent-skills-androidtheir own version, first seen Oct 3, 2026
- addyosmani/agent-skillstheir own version, first seen Oct 3, 2026
- weisser-dev/agentic-skillstheir own version, first seen Oct 3, 2026
- JPeetz/agent-skillstheir own version, first seen Sep 29, 2026
- iuliandita/skillstheir own version, first seen Sep 24, 2026
- ZeroTokenClaw/agents-skillstheir own version, first seen Sep 21, 2026
Used with
Projects with it also use constraint-driven-development, observability-and-instrumentation and 10 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.
vinvcnSkillconstraint-driven-development
把一个项目的质量线确立为书面契约,并阻止 agent 悄悄降低它。通过访谈确定用户在意哪些维度,当用户心里没有数字时提供合理的默认阈值,把一切记录进 CONSTRAINTS.md,并盯住 diff 中质量线被削弱的迹象——新增的 @ts-ignore 或 eslint-disable 抑制注释、被跳过或删除的测试、被剥掉的断言、未实现的 stub、被调低的阈值。当没有任何质量线被写下来时使用;当用户说 "set up constraints" 或 "define our standards" 时;当用户希望把他们在意的维度——无障碍性、Web 性能、覆盖率——设置成被强制执行的约束时;当 agent 为了变绿不断静默检查或跳过测试时;当你需要一个覆盖率或性能阈值却不知道该选什么数字时;或者当 agent 写下的代码超出任何人会读的体量时。
Also in 4 projects that use this
borhen68Skillobservability-and-instrumentation
Instruments code so production behavior is visible and diagnosable. Use when adding logging, metrics, tracing, or alerting. Use when shipping any feature that runs in production and you need evidence it works. Use when production issues are reported but you can't tell what happened from the available data.
Also in 13 projects that use this
mycelium-hqSkilldoubt-driven-development
Use when correctness matters more than speed: about to commit non-trivial code, make an architectural call under uncertainty, work in unfamiliar code, or assert what the compiler cannot check (''this is safe'', ''thread-safe'', ''this scales'', ''matches the spec''). Strongest on high-stakes surfaces (production deploys, security-sensitive logic, data migrations, irreversible operations) and when the user asks to sanity-check, red-team, double-check, or get a second opinion on a decision.
Also in 19 projects that use this
galandoSkillsource-driven-development
Version-aware, source-driven development — fetch official docs before writing framework code
Also in 23 projects that use this
luischanciSkillinterview-me
Interactive interview to formalize a research idea into a structured specification with hypotheses and empirical strategy.
Also in 16 projects that use this
Jonathan0823Skillminimalist-ui
Clean editorial-style interfaces. Warm monochrome palette, typographic contrast, flat bento grids, muted pastels. No gradients, no heavy shadows.
Also in 4 projects that use this
Other versions46 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 46
- addyosmani/agent-skills★ 101ksame name
- shashankswe2020-ux/whoop-mcp★ 165same name
- HybridAIOne/hybridclaw★ 157same name
- muratgur/ordinus★ 109same name
- thiientv/godmode★ 96same name
- tranhieutt/software_development_department★ 72same name
- c-kick/hnl-agent-skills★ 51same name
- az9713/addyosmani-agent-skills★ 38same name
- vinvcn/addyosmani-agent-skills-zh★ 38same name
- jmxt3/gitscape.ai★ 32same name
36 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 45 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 45 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.

