code-simplification
Skill33 starsChanged 4 months agoApache-2.0View on GitHub
Simplifies code for clarity. Use when refactoring code for clarity without changing behavior. Use when code works but is harder to read, maintain, or extend than it should be. Use when reviewing code that has accumulated unnecessary complexity.
We split this skill into the rules it gives an agent
9 rules. 0 are common, 8 are distinctive, and 1 is very specific to this project.
0
Common
Most of the 72 edited versions we read keep these.
8
Distinctive
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 27
Before simplifying any code, answer: why was it written this way?
- Distinctive: line 33
Read the function end-to-end
- Distinctive: line 34
Read its callers — what do they expect?
- Distinctive: line 35
Read its tests — what behavior is verified?
- Very specific: line 36
Check git history: git log -p -- path/to/file.py
- Distinctive: line 41
If the code lacks tests, add tests before simplifying.
- Distinctive: line 50
Run them, confirm they pass.
- Distinctive: line 169
Run the full test suite after each simplification:
- Distinctive: line 175
If any test fails, revert that specific simplification and reconsider.
“Common” is measured: kept by at least 6 in 10 of the 72 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
Code Simplification
Overview
Reduce complexity while preserving exact behavior. The goal is code that a new engineer can read and understand without asking the author questions. Simplification is not optimization — do not change performance characteristics unless that is the explicit goal.
When to Use
- Code works but is harder to read than it should be
- A function is doing more than one thing
- Nested conditionals make the control flow hard to follow
- Variable names are generic (
data,result,temp) - The same logic appears in multiple places
- A reviewer needed to ask what the code does
When NOT to use: Code that is intentionally complex for performance reasons (document with a comment instead of simplifying).
The Chesterton's Fence Rule
"Don't remove a fence you don't understand."
Before simplifying any code, answer: why was it written this way? If you can't answer that, you risk removing a safeguard. Read the git history, grep for related tests, and understand the intent before changing anything.
The Simplification Process
Step 1: Understand Before Touching
- Read the function end-to-end
- Read its callers — what do they expect?
- Read its tests — what behavior is verified?
- Check git history:
git log -p -- path/to/file.py - Do not change anything yet
Step 2: Cover First
If the code lacks tests, add tests before simplifying. You need a safety net:
def test_generate_skill_name_sanitizes_input():
assert generate_skill_name("my repo") == "my-repo"
assert generate_skill_name("My Repo!") == "my-repo"
assert generate_skill_name(" spaces ") == "spaces"Run them, confirm they pass. Now you can simplify safely.
Step 3: Apply Simplifications Incrementally
Apply one simplification at a time, running tests after each:
Deep Nesting → Guard Clauses
# BAD: Pyramid of doom
def process_skill(skill):
if skill is not None:
if skill.get("name"):
if len(skill["name"]) > 0:
return skill["name"].lower()
return None
return None
# GOOD: Guard clauses
def process_skill(skill):
if not skill:
return None
if not skill.get("name"):
return None
return skill["name"].lower()Long Functions → Extracted Helpers
# BAD: One function doing three jobs
def export_skill(repo: str) -> bytes:
# Fetch files
files = []
for branch in ["main", "master"]:
try:
contents = github_client.get_contents(repo, branch)
files = contents
break
except Exception:
continue
# Filter relevant files
relevant = [f for f in files if f.path.endswith((".md", ".py", ".ts"))]
# Build zip
buf = io.BytesIO()
with zipfile.ZipFile(buf, "w") as zf:
for f in relevant:
zf.writestr(f.path, f.decoded_content)
return buf.getvalue()
# GOOD: Each function does one thing
def export_skill(repo: str) -> bytes:
files = fetch_repo_files(repo)
relevant = filter_skill_files(files)
return build_zip(relevant)
def fetch_repo_files(repo: str) -> list:
for branch in ["main", "master"]:
try:
return github_client.get_contents(repo, branch)
except Exception:
continue
return []
def filter_skill_files(files: list) -> list:
return [f for f in files if f.path.endswith((".md", ".py", ".ts"))]
def build_zip(files: list) -> bytes:
buf = io.BytesIO()
with zipfile.ZipFile(buf, "w") as zf:
for f in files:
zf.writestr(f.path, f.decoded_content)
return buf.getvalue()Generic Names → Descriptive Names
# BAD
def process(d, r):
result = []
for item in d:
if item["type"] == r:
result.append(item)
return result
# GOOD
def filter_files_by_type(files: list[dict], file_type: str) -> list[dict]:
return [f for f in files if f["type"] == file_type]Duplicated Logic → Shared Functions
# BAD: Same validation in three places
def create_skill(name: str):
if not name or len(name) > 100:
raise ValueError("Invalid name")
...
def update_skill(name: str):
if not name or len(name) > 100:
raise ValueError("Invalid name")
...
# GOOD
def validate_skill_name(name: str) -> None:
if not name or len(name) > 100:
raise ValueError("Skill name must be 1-100 characters")
def create_skill(name: str):
validate_skill_name(name)
...Step 4: Verify Nothing Changed
Run the full test suite after each simplification:
pytest tests/ -vIf any test fails, revert that specific simplification and reconsider. Simplification must not change behavior.
Step 5: Review the Result
After simplifying, ask:
- Can a new engineer read this function without asking questions?
- Is the control flow obvious?
- Does every name say what the thing is, not what it does mechanically?
- Are there any functions over 30 lines that could be split?
The Rule of 500
A file over 500 lines is a sign it's doing too much. Consider splitting. For GitScape:
api/app/skill_builder.py— if over 500 lines, split intoname_sanitizer.py,file_filter.py,assembler.pyweb/components/SkillExport.tsx— if over 500 lines, split by concern
Common Rationalizations
| Rationalization | Reality |
| "I understand the code" | You wrote it. Someone else reads it cold at 11 PM during an incident. |
| "Extracting functions adds overhead" | Modern runtimes inline trivially. The overhead is unmeasurable. The clarity is immediate. |
| "The code is complex because the problem is complex" | Complex problems have simple solutions and complex solutions. Always look for the simpler one. |
| "I shouldn't touch it — it works" | Working code that no one understands becomes legacy code that no one can change safely. |
Red Flags
- Functions over 30 lines
- Nesting deeper than 3 levels
- Variables named
data,result,temp,info - Comments that explain what the code does (rewrite instead)
- Duplicated logic (copy-paste is a red flag)
- Boolean parameters that change the function's behavior (
create_skill(name, dry_run=True))
Verification
After simplification:
- All tests still pass (no behavior change)
- The diff is a net reduction in lines (usually)
- No function is over 30 lines
- No variable is named
data,result, ortemp - Duplicated logic has been extracted to a shared function
- No comments that explain what the code does (only why)
Other versions78 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 78
- addyosmani/agent-skills★ 112ksame name
- sanity-io/sanity★ 6.4ksame name
- rizqinrr/viserys-agent★ 560same name
- luxury-yacht/app★ 444same name
- shashankswe2020-ux/whoop-mcp★ 174same name
- sammcj/agentic-coding★ 167same name
- HybridAIOne/hybridclaw★ 159same name
- muratgur/ordinus★ 111same name
- tranhieutt/software_development_department★ 71same name
- lgbarn/shipyard★ 66same name
68 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.
Used alongsideProjects with it also use constraint-driven-development, security-best-practices and 7 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 17 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
xfstudioSkillarchitecture-decision-records
Write and maintain Architecture Decision Records (ADRs) following best practices for technical decision documentation. Use when documenting significant technical decisions, reviewing past architectural choices, or establishing decision processes.
Also in 4 projects that use this
GitHubSkillconventional-commit
Prompt and workflow for generating conventional commit messages using a structured XML format. Guides users to create standardized, descriptive commit messages in line with the Conventional Commits specification, including instructions, examples, and validation.
Also in 3 projects that use this
IgorGanapolskySkillgraphify
Query the local Graphify-Labs AST knowledge graph for ThumbGate architecture questions (what connects X to Y, explain a symbol, PreToolUse/gates/adapters). Slash: /graphify.
Also in 5 projects that use this
rogue-dev-studioSkillbrowser-automation
Canonical browser automation and web UI verification: Playwright, agent browser CLIs, and CDP-based tooling in one playbook.
Also in 3 projects that use this
In this repository53 other files it gives its agents.
- .agents/AGENTS.mdAGENTS.md
- ad-creativeSkill
- addyosmani-agent-skillsSkill
- api-and-interface-designSkill
- brandkitSkill
- browser-testing-with-devtoolsSkill
- chef-assistantSkill
- ci-cd-and-automationSkill
- cloud-run-basicsSkill
- code-review-and-qualitySkill
- context-engineeringSkill
- debugging-and-error-recoverySkill
- deprecation-and-migrationSkill
- design-taste-frontendSkill
- design-taste-frontend-v1Skill
- documentation-and-adrsSkill
- frontend-ui-engineeringSkill
- full-output-enforcementSkill
- gemini-apiSkill
- git-workflow-and-versioningSkill
- googlecloudplatform-knowledge-catalogSkill
- google-cloud-recipe-authSkill
- google-cloud-recipe-networking-observabilitySkill
- google-cloud-recipe-onboardingSkill
- google-cloud-waf-cost-optimizationSkill
- google-cloud-waf-reliabilitySkill
- google-cloud-waf-securitySkill
- gpt-tasteSkill
- high-end-visual-designSkill
- imagegen-frontend-mobileSkill
- imagegen-frontend-webSkill
- image-to-codeSkill
- incremental-implementationSkill
- industrial-brutalist-uiSkill
- marketing-ideasSkill
- minimalist-uiSkill
- nvidia-skillspectorSkill
- observability-and-instrumentationSkill
- performance-optimizationSkill
- planning-and-task-breakdownSkill
- pricing-strategySkill
- programmatic-seoSkill
- redesign-existing-projectsSkill
- security-and-hardeningSkill
- seo-auditSkill
- shipping-and-launchSkill
- social-contentSkill
- source-driven-developmentSkill
- spec-driven-developmentSkill
- stitch-design-tasteSkill
- test-driven-developmentSkill
- using-agent-skillsSkill
- videoSkill
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.

