/shipyard:code-simplificationfrom shipyard
Finds and removes duplication, dead code, over-engineering, and AI-generated bloat. Use after implementing features, before shipping, or when code feels overly complex.
Ships in shipyard. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
The simplifier agent references this skill for systematic cross-task analysis.
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.
When reviewing code for simplification:
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 project
Parallel hierarchies: When adding a new type requires changes in multiple places.
Copy-paste config: Same configuration blocks repeated in Docker, Terraform, or CI files.
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.10
Replace conditionals with polymorphism: When type-checking drives behavior.
Simplify boolean expressions: Collapse nested boolean logic.
| 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 |
# 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.
# 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)
# OVER-ENGINEERED
MAX_RETRIES = config.get("max_retries", 3)
# SIMPLE (if this is the only place retries happen)
MAX_RETRIES = 3
Rule: Make it configurable when a second consumer needs a different value, not before.
AI code generators commonly produce these patterns. Watch for them:
# 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 user
# 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...
# 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)
# 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)
# 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
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_body
Priority: High -- 3 exact duplicates, Rule of Three applies.
| 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. |
Referenced by:
Pairs with:
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub lgbarn/shipyard --plugin shipyard19 skills in this plugin
/documentationGenerates and updates code docs, README files, API docs, and architecture documentation. Use when a feature with public interfaces lacks docs, when documentation is incomplete or outdated, or before shipping any phase. Also use when adding breaking changes or complex algorithms, or when a public function lacks a docstring./git-workflowManages branches, worktrees, atomic commits, and branch completion by merge, PR, preserve, or discard. Use when starting feature work that needs a branch or an isolated workspace, making commits during development, or finishing a development branch. Also use when the user says "set up worktree", "create PR", "finish this branch", or "start feature"./import-specImports a spec-kit feature spec into Shipyard in place of brainstorming. Use when a spec-kit feature directory with spec.md exists./import-spec-fileImports a handwritten spec document into Shipyard in place of brainstorming. Use when a freeform spec, requirements, or design document already exists./infrastructure-validationValidates infrastructure-as-code with tool chains and checks for common mistakes. Use when working with Terraform (.tf, .tfvars), Ansible (playbooks, roles, inventory), Docker (Dockerfile, docker-compose.yml), Kubernetes (manifests, Helm charts), or CloudFormation. Also use when running terraform plan/apply, building Docker images, writing Helm templates, or when IaC changes touch security groups, IAM policies, or secrets./lessons-learnedExtracts reusable lessons from completed work. Use when a phase or milestone is complete, before shipping, or when reflecting on finished work. Also use when the user says "what did we learn", "capture lessons", "retrospective", "wrap up", "ship this phase", or "done with this phase". A phase must not ship without lesson capture.Other plugins' skills for the same job