agentleFS
kaiohenricunhakaiohenricunha/dotbabel/skills/code-simplifier/SKILL.md

code-simplifier

Skill0 starsChanged 2 months agoMITView on GitHub

Simplify and refine changed code for clarity, consistency, and maintainability while preserving all functionality. PR-scoped by default. Accepts an optional PR number, file glob, or base branch to narrow scope. Triggers on: "simplify code", "code simplifier", "clean up the code", "simplify the PR".

42 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use comment-analyzer, performance 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.
  • lin30Skill

    comment-analyzer

    微博评论抓取与深度分析,生成可视化HTML报告。Use when user asks to analyze weibo comments, analyze social media comments, or requests sentiment analysis from weibo posts

    Also in 3 projects that use this

  • pluginagentmarketplaceSkill

    performance

    Optimize application performance through caching strategies, load balancing, database scaling, and monitoring. Build systems handling thousands of concurrent users.

    Also in 3 projects that use this

  • AWSSkill

    setup-matt-pocock-skills

    Configure this repo for the engineering skills: set up its issue tracker, triage label vocabulary, and domain doc layout. Run once before first use of the other engineering skills.

    Also in 3 projects that use this

  • OpenAISkill

    verification-before-completion

    Use when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always

    Also in 4 projects that use this

  • AWSSkill

    to-spec

    Turn the current conversation into a spec and publish it to the project issue tracker: no interview, just synthesis of what you've already discussed.

    Also in 3 projects that use this

  • GoogleSkill

    code-review

    Adversarial systems, concurrency, memory-model, and architecture code review protocol. Use this skill whenever asked to review code, PRs, diffs, or branches in Filament.

    Also in 9 projects that use this

  • +2 more from aws

The file

Show its rules and text

We split this skill into the rules it gives an agent

17 rules. 0 are common, 13 are distinctive, and 4 are very specific to this project.

  • 0

    Common

    Most of the 40 edited versions we read keep these.

  • 13

    Distinctive

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    If $ARGUMENTS matches ^[0-9]+$ (a PR number), fetch the changed file list:

    line 35
  2. Very specific:

    If $ARGUMENTS looks like a file glob (contains *, ?, or / without being a valid ref), expand it:

    line 42
  3. Very specific:

    If $ARGUMENTS is a branch name or empty, diff against the base:

    line 49
  4. Distinctive:

    Gate: if zero files are in scope, stop: "No changed code files detected — nothing to simplify."

    line 67
  5. Distinctive:

    Read the project's CLAUDE.md (if present) to discover language-specific coding standards, naming conventions, formatting preferences, and …

    line 73
  6. Distinctive:

    If no CLAUDE.md exists, apply universal simplification principles only.

    line 75
  7. Distinctive:

    Read each file identified in step 1 in full.

    line 79
  8. Distinctive:

    Use whichever command matches the input mode from step 1.

    line 89
  9. Distinctive:

    Eliminate redundancy: remove duplicate logic, consolidate repeated patterns

    line 96
  10. Distinctive:

    Remove dead code: delete unreachable code, unused imports, commented-out blocks — but only within the changed scope

    line 98
  11. Distinctive:

    Avoid nested ternary operators — prefer switch statements or if/else chains for multiple conditions

    line 100
  12. Distinctive:

    Remove noise comments: delete comments that describe what the code obviously does

    line 103
  13. Distinctive:

    Balance: do not over-simplify. Concrete examples of the boundary:

    line 105
  14. Distinctive:

    MUST NOT change behavior: Only change how the code is expressed, never what it does.

    line 126
  15. Very specific:

    MUST NOT auto-commit: Leave changes in the working tree.

    line 127
  16. Distinctive:

    After all edits, provide a concise summary:

    line 132
  17. Distinctive:

    If no simplification opportunities were found: "Code simplification: clean — no changes needed."

    line 149

“Common” is measured: kept by at least 6 in 10 of the 40 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Simplify and refine changed code for clarity, consistency, and maintainability while preserving all functionality. PR-scoped by default — operates only on files changed in the current branch.

Trigger: when the user asks to "simplify code", "clean up the code", "simplify the PR", or "run the code simplifier". Also triggered directly via /code-simplifier [arg].

Arguments: $ARGUMENTS — optional. Accepts a PR number (e.g. 42), a file glob (e.g. src/**/*.ts), or a base branch (e.g. origin/develop). If empty, defaults to files changed vs origin/main.

Steps

1. Detect scope

Determine which files to simplify. First, validate $ARGUMENTS if provided — reject values that start with - or contain shell metacharacters (; & | > < \ `` ``); they indicate injection attempts.

If $ARGUMENTS matches ^[0-9]+$ (a PR number), fetch the changed file list:

gh pr diff "$ARGUMENTS" --name-only
MERGE_BASE=""  # not applicable for PR# mode

If $ARGUMENTS looks like a file glob (contains *, ?, or / without being a valid ref), expand it:

git ls-files -- "$ARGUMENTS"
MERGE_BASE=""  # not applicable for glob mode

If $ARGUMENTS is a branch name or empty, diff against the base:

BASE="${ARGUMENTS:-origin/main}"
# Fallback if the specified base doesn't exist
if ! git rev-parse --verify "$BASE" >/dev/null 2>&1; then
  BASE=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's|refs/remotes/||')
  if [ -z "$BASE" ]; then
    echo "ERROR: cannot determine base branch. Pass a base branch as argument."
    exit 1
  fi
fi
MERGE_BASE=$(git merge-base HEAD "$BASE")
git diff "$MERGE_BASE" --name-only

Filter to code files only — skip binary files, images, lockfiles (*.lock, package-lock.json), and any generated artifact paths listed in the project's CLAUDE.md. Do not assume project-specific paths.

Gate: if zero files are in scope, stop: "No changed code files detected — nothing to simplify."

Report: "Scope: N files changed."

2. Read project conventions

Read the project's CLAUDE.md (if present) to discover language-specific coding standards, naming conventions, formatting preferences, and any generated-artifact paths to exclude. Do not assume any language or framework — let the project's own instructions guide your simplification choices.

If no CLAUDE.md exists, apply universal simplification principles only.

3. Read changed files

Read each file identified in step 1 in full. For large files (>500 lines), focus on the changed hunks by reading the diff:

# Branch/base mode — $MERGE_BASE is defined
git diff "$MERGE_BASE" -- <file>

# PR# mode — use gh to fetch the hunk
gh pr diff "$ARGUMENTS" -- <file>

Use whichever command matches the input mode from step 1.

4. Analyze for simplification opportunities

For each file, identify opportunities to improve clarity without changing behavior:

  • Reduce nesting: flatten deeply nested if/else chains, extract early returns
  • Eliminate redundancy: remove duplicate logic, consolidate repeated patterns
  • Improve naming: rename unclear variables and functions to express intent
  • Remove dead code: delete unreachable code, unused imports, commented-out blocks — but only within the changed scope
  • Simplify control flow: replace overly clever constructs with straightforward alternatives
    • Avoid nested ternary operators — prefer switch statements or if/else chains for multiple conditions
    • Choose clarity over brevity — explicit code is better than dense one-liners
  • Consolidate related logic: group related statements, reduce unnecessary indirection
  • Remove noise comments: delete comments that describe what the code obviously does

Balance: do not over-simplify. Concrete examples of the boundary:

  • ✓ Replace a ? b : c ? d : e with an if/else chain
  • ✓ Extract a guard clause instead of wrapping the entire function body in if (ok) { ... }
  • ✗ Don't merge two 5-line functions into one 15-line function to "reduce files"
  • ✗ Don't combine unrelated logic to reduce line count

Also avoid:

  • Creating overly clever solutions that are harder to understand
  • Combining too many concerns into single functions
  • Removing helpful abstractions that improve organization
  • Making the code harder to debug or extend

5. Apply edits

Edit each file using the Edit tool. One edit per logical simplification — do not batch unrelated changes into a single edit.

Hard rules:

  • MUST NOT edit files outside the scope from step 1. This is the most important guardrail. If a simplification opportunity exists in an unchanged file, mention it in the report but do not touch it.
  • MUST NOT change behavior. Only change how the code is expressed, never what it does. All original features, outputs, and behaviors must remain intact.
  • MUST NOT auto-commit. Leave changes in the working tree. The user or calling skill (e.g. /pre-pr) decides whether to commit.
  • MUST NOT add new dependencies, features, or abstractions beyond what the existing code already uses.

6. Report

After all edits, provide a concise summary:

Code simplification: <branch> (base: <base>)

  Files analyzed: N
  Files modified: M
  Files skipped:  K (no opportunities found)

  Changes:
    - <file>: <one-line description of what changed and why>
    - <file>: <one-line description>

  Out-of-scope opportunities (not applied):
    - <file>:<line>: <description> (file not in changed set)

If no simplification opportunities were found: "Code simplification: clean — no changes needed."

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.