AGENT SKILL

code-simplifier

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".

适用职业开发工程师
License 许可
MIT
最近更新
2026-10-26
Stars
★ 0
Forks
0

01 前言 Front Matter

id
code-simplifier
name
code-simplifier
task
[ "review" ]
type
skill
model
sonnet
owner
@kaiohenricunha
tools
Read, Grep, Glob, Bash, Edit
domain
[ "devex" ]
created
1778457600000
updated
1778457600000
version
1.0.0
dotbabel
{ "compute": { "mode": "dynamic", "binding": "consumer", "rationale": "Scoped engineering follows an existing implementation or review workflow with checkable results.", "requirement": "routine" } }
maturity
draft
platform
[ "none" ]
description
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".
argument-hint
[PR# | file-glob | base-branch]

03 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."

04 同仓库更多 Skills

kaiohenricunha
kaiohenricunha/dotbabel

yolo

Start temporary autonomy for the current task or an explicit scope with a required --for expiry. Codex permits scoped pushes, merges, deploys, and releases after strict testing and validation; Full access is a separate runtime setting. Claude Code uses a session permission hook with a protected-action denylist.

开发工程师
★ 0
kaiohenricunha
kaiohenricunha/dotbabel

veracity-audit

Audit a data pipeline for Veracity and Value. Dispatches data-scientist, compliance-auditor, and data-engineer agents with project context injected at dispatch time. All source paths are supplied via flags — no defaults, no project assumptions. Subcommands: audit (full pipeline walk), score-check (scoring math only), gate-check (gate coverage only), source-trace <label> (single source end-to-end). Invoke when: "audit pipeline", "veracity check", "scoring math correct?", "check gates", "trace source", "verify quality gates", "formula correct?".

律师与法务Skill与智能体开发
★ 0
kaiohenricunha
kaiohenricunha/dotbabel

validate-spec

Audit an already-implemented spec against the codebase. Walks each constraint (ARCH-N, PERF-N, KD-N, etc.) and acceptance criterion, grounds findings in file:line evidence, runs the spec.json acceptance_commands, and writes a single audit doc to docs/audits/. Use whenever the user asks to "validate a spec", "audit a spec", "check if spec is implemented", "verify the spec is done", "is this spec really done", or otherwise wants closure on spec-driven work. Read-only against the spec — produces an audit, never modifies the spec itself.

★ 0
kaiohenricunha
kaiohenricunha/dotbabel

terragrunt-specialist

Deep-dive Terragrunt hierarchy review, DRY pattern audits, and run-all orchestration analysis. Use for structured investigations of multi-environment Terragrunt layouts, dependency graphs, remote state config, and hook correctness. Triggers on: "Terragrunt audit", "run-all review", "dependency block", "DRY pattern review", "env hierarchy audit", "mock_outputs", "terragrunt hooks".

运维与部署
★ 0
kaiohenricunha
kaiohenricunha/dotbabel

terraform-specialist

Deep-dive Terraform architecture review, module design, state management, and migration. Use for structured investigations of Terraform workspaces, provider configuration, module coupling, import workflows, and test coverage. Triggers on: "Terraform audit", "module review", "state management", "Terraform import", "workspace design", "provider config review", "Terraform testing".

测试与质量运维与部署
★ 0
kaiohenricunha
kaiohenricunha/dotbabel

spec

Create structured engineering specs through interactive pairing. Use when the user wants to create a spec, design doc, technical specification, architecture document, RFC, or engineering plan. Triggers on "let's spec this out", "create a spec", "design doc", "write a technical plan", "plan the architecture". Works for greenfield and brownfield projects. Outputs to docs/specs/.

设计师视觉设计
★ 0