code-simplification
Skill32 starsChanged 5 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.
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, doubt-driven-development and 4 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
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
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
CloudflareSkillreceiving-code-review
Use when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementation
Also in 6 projects that use this
OpenAISkillrequesting-code-review
Use when completing tasks, implementing major features, or before merging to verify work meets requirements
Also in 5 projects that use this
OpenAISkillexecuting-plans
Use when you have a written implementation plan to execute in a separate session with review checkpoints
Also in 5 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
- lgbarn/shipyard★ 66same name
- c-kick/hnl-agent-skills★ 51same name
- az9713/addyosmani-agent-skills★ 38same name
- vinvcn/addyosmani-agent-skills-zh★ 38same 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 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
The file
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 45 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 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
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)
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.

