Agent skill

Spec Simplify Code

by leo-kuang-ai in leo-kuang-ai/spec-first

Simplify recently changed code for clarity, reuse, quality, and efficiency while preserving behavior.

MITAuto-check passedDevelopment

Install Spec Simplify Code

skills CLI
$ npx skills add leo-kuang-ai/spec-first --skill spec-simplify-code -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install leo-kuang-ai/spec-first spec-simplify-code --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/leo-kuang-ai/spec-first.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/spec-simplify-code .claude/skills/spec-simplify-code && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
spec-simplify-code
GitHub stars
107
Token cost
~2.4k tokens
SKILL.md length
1,230 words
Files
22 (incl. references)
Skills in repo
35
Repo updated
First seen
Licence
MIT

At a glance

Simplify recently changed code for clarity, reuse, quality, and efficiency while preserving behavior.

  • Works in 5 steps: Identify scope → Run 3 review lenses → Fix issues → …
  • Tidy/refactor passes
  • SKILL.md covers Step 1: Identify scope, Step 2: Run 3 review lenses, Step 3: Fix issues and Step 4: Verify behavior is…, plus 1 more section
  • Runs JavaScript scripts from its folder; calls git

What it does

Spec Simplify Code is an agent skill from leo-kuang-ai/spec-first. Simplify recently changed code for clarity, reuse, quality, and efficiency while preserving behavior. Use for tidy/refactor passes; use spec-debug for bugs. Not for new features or behavior changes.

Its SKILL.md is about 2.4k tokens, which your agent loads only when the skill is triggered. The skill folder holds 29 other files, including reference files (for example `evals/cases/bug-request-routes-debug.yaml`, `evals/cases/docs-only-no-yield.yaml` and `evals/cases/r2-elegant-refactor.yaml`).

It sits in Development, covering Code simplification. It works with Git. The repository describes itself as: 仓库原生 AI Coding Harness —— 把一次性 AI 对话变成可治理、可验证、可沉淀的工程闭环 · spec-first.cn. The licence is MIT.

When your agent uses it

  • Tidy/refactor passes
  • Use spec-debug for bugs

Example prompts

  • “/spec-simplify-code”

Requirements

  • Node.js

Workflow steps

5 steps, taken from the step headings in SKILL.md.

  1. Identify scope
  2. Run 3 review lenses
  3. Fix issues
  4. Verify behavior is preserved
  5. Summarize

What it can do on your machine

Read from SKILL.md and the folder at commit 74655dc. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships script files (JavaScript, from the files we listed), which the agent can run.

    Shell commands in SKILL.md call:

    • git

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use git, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Spec Simplify Code loads about 2.4k tokens when it runs, and up to ~3.9k if it reads all its reference files. Until then it costs about 54 tokens; SKILL.md has 1,230 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~54
When it runs · the whole SKILL.md, loaded when a task matches
~2.4k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~3.9k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from leo-kuang-ai/spec-first at commit 74655dc, republished under its MIT licence (© leo-kuang-ai). 1,230 words, ~2,354 tokens.

Download SKILL.mdSave it as .claude/skills/spec-simplify-code/SKILL.md (or your agent's skills folder). This skill also uses 21 other files; get the full folder from GitHub.
name
spec-simplify-code
description
Simplify recently changed code for clarity, reuse, quality, and efficiency while preserving behavior. Use for tidy/refactor passes; use spec-debug for bugs. Not for new features or behavior changes.
argument-hint
[blank to simplify current branch changes, or describe what to simplify]

Simplify recently changed code for clarity, reuse, quality, and efficiency while preserving exact behavior. Prioritize readable, explicit code over compact code — fewer lines is not the goal.

Step 1: Identify scope

Not-a-simplification input first. A request that reports broken behavior — a crash, a failing test, wrong output — is a bug, not a simplification pass. Do not fix the bug here. Name spec-debug in the reply and route out; the caller can return for a behavior-preserving cleanup after the fix lands.

Resolve the simplification scope in this order:

  1. If the user explicitly named a scope (a file, a directory, "the function I just wrote", "the changes from this morning"), use that scope. Treat user-named scope as authoritative — do not widen it.
  2. Otherwise, in a git repository, default to the diff between the current branch and its base branch (e.g., git diff origin/main... or against the configured upstream). This covers the common case of "simplify everything I've added on this feature branch before opening a PR." If the branch has no upstream or base ref, fall back to staged + unstaged changes (git diff HEAD).
  3. Outside a git repository or when no diff is available, review the most recently modified files mentioned by the user or edited earlier in this conversation.

If none of the above produces a non-empty scope, stop and ask the user what to simplify rather than guessing. Use the platform's blocking question tool: AskUserQuestion in Claude Code (call ToolSearch with select:AskUserQuestion first if its schema isn't loaded), request_user_input in Codex. Fall back to numbered options in chat only when no blocking tool exists in the harness or the call errors (e.g., Codex edit modes) — not because a schema load is required. Never silently skip the question.

Preflight — skip a no-yield scope before loading review lenses. If the resolved scope contains no substantive human-authored code and consists only of documentation/Markdown, generated or vendored files, dependency/lockfiles, or purely mechanical formatting, lint, or mass-rename churn, stop with a one-line nothing to simplify result. On a mixed diff, narrow the scope to the substantive code files. This is a change-kind gate, not a size threshold, and it never widens beyond caller-authorized paths.

When the caller provides a plan as context, the plan is not additional simplification scope. Preserve any session-settled: structural decisions: deliberately separate implementations or duplicated package-local runtime assets remain separate even when consolidation would otherwise look cleaner.

Step 2: Run 3 review lenses

在派发 reviewer 前记录:

yaml
worker_dispatch_authorization: authorized | missing
capability_probe: not_applicable | attempted | unavailable
worker_dispatch_capability: available | missing | unknown
worker_context_isolation: isolated | inherited | unknown
worker_model_override: supported | unsupported | unknown
worker_bounded_parallelism: supported | unsupported | unknown

workflow invocation does not authorize dispatch。只有当前用户或可见 upstream handoff 明确请求 subagent、delegated work、persona 或 parallel work 时,才可把三个 review lens 派发给 generic workers。缺授权时不得探测 tool schema,固定为 capability_probe: not_applicable + worker_dispatch_capability: unknown,inline 或 serial 执行全部三个 lens 并记录 dispatch_authorization_missing。只有授权后才把 current-session registry/schema 作为 provider_untrusted evidence 检查:确认缺失时记录 subagent_capability_missing;surface 不可用、schema 不完整或候选不唯一时记录 worker_capability_unproven,均 inline 或 serial。隔离、模型覆盖和有界并发只取 live facts;required isolation 未满足时保持依赖 gate 打开,model unknown 时继承,parallelism unknown 时串行。记录 worker_dispatch_outcome。Inline fallback 保留三个 rubric 的完整覆盖,但不得声称三个 independent reviewers 或 multi-agent coverage。

When authorization is present and the current-session semantic probe yields one eligible generic worker candidate, dispatch three bounded workers — code-reuse, code-quality, and efficiency reviewers. Otherwise run the reviews inline or serially. For each reviewer or inline lens, read its prompt asset from this skill's directory and use the full file content together with the resolved scope (the full diff or file set) so the review has complete context:

  • references/personas/code-reuse-reviewer.md — existing utilities, duplicated functionality, reimplemented stdlib/runtime primitives.
  • references/personas/code-quality-reviewer.md — redundant state, parameter sprawl, copy-paste, leaky abstractions, stringly-typed code, dead code, over-nesting, and the over-simplification balance guard.
  • references/personas/efficiency-reviewer.md — unnecessary work, missed concurrency, hot-path bloat, no-op updates, memory leaks.

Do not paraphrase these rubrics from memory — read each file and pass it verbatim, or the reviewer loses the gating rules that keep the pass behavior-preserving.

Bounded dispatch. When dispatch is authorized and available, queue the three reviewers and launch only as many as the harness accepts at once; treat a concurrency/active-agent-limit error as backpressure (leave the reviewer queued and retry after a slot frees), not as reviewer failure. Inline fallback runs the lenses serially when shared context or edit overlap makes concurrency unsafe.

Model selection. Request the balanced mid-tier only when worker_model_override: supported and the current schema exposes an explicit selector. Otherwise omit the override, inherit the parent model, and record model_override_unsupported or model_override_unknown as applicable; task wording alone does not select a different model.

Permission mode. For an authorized dispatch, omit the mode parameter so the user's configured permission settings apply. Permission settings are execution conditions, not dispatch authorization.

Show full SKILL.md (501 more words)Show less

Step 3: Fix issues

Complete all three review lenses, whether dispatched or inline. Aggregate their findings and fix each issue directly. If a finding is a false positive or not worth addressing, note it and move on. Do not argue with the finding or raise questions to the user, just skip it.

Before applying each fix, confirm it preserves behavior: same output for every input, same error behavior, and same side effects and ordering. If a fix can't clear that test, skip it — automated checks in Step 4 don't cover every behavior.

Never simplify away a safety check. Input validation at trust boundaries, error handling that prevents data loss, security checks (authorization, escaping, sanitization), and accessibility affordances are not removable boilerplate — preserve them even when a finding frames them as redundant or inline-able. Code that drops one of these is not simpler, it is unfinished. If a proposed simplification would thin or remove one, skip it.

Step 4: Verify behavior is preserved

The premise of this skill is that simplification preserves exact functionality. After applying fixes:

Run typecheck and lint over the full project. They are usually fast and catch the most common simplification regressions — broken imports, unused exports, dropped type narrowings, dead code other modules still reference.

Run tests:

  • Run tests scoped to the changed paths. CI runs the full suite on PR — this local check is a fast signal, not the final guarantee. Match scope to blast radius; a 3-line simplification doesn't warrant a 20-minute test run.
  • Broaden scope when the change has obvious wide reach — e.g., a heavily-imported utility was rewritten, or the code-quality reviewer's consolidation/dedup fixes modified shared code. This is a judgment call about ripple risk, not a mechanical rule.
  • If the test runner has no scoping mechanism, run the full suite.

Surface any failure clearly with the failing check name and the relevant output. Do not relax assertions, weaken type signatures, or skip tests to make checks pass — that defeats the "preserves functionality" guarantee. Either fix the underlying break introduced by simplification, or revert the specific change that caused the regression.

If no test suite, lint, or typecheck is configured, state that explicitly in the summary; do not silently skip verification.

Step 5: Summarize

Briefly summarize what was good vs improved and fixed, including which checks were run and their results. If there were no findings to act on, confirm the code didn't require any changes.

Quantify the impact by dimension. Report what was actually applied, not a line count: fixes applied per reviewer dimension (reuse, quality, efficiency), how many findings were skipped as false-positive or not worth addressing, and the behavior-preservation result (checks run and outcome). For example: "Applied 6 — reuse 2, quality 3, efficiency 1; skipped 2 false positives; typecheck + lint clean, 11 scoped tests pass." Do not headline a net-lines-removed figure or frame fewer lines as the win — many clarity, safety, and efficiency fixes preserve or add lines. The measure is what improved and that behavior held, not how much code shrank.

© leo-kuang-ai, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 21 other files (references) in skills/spec-simplify-code of leo-kuang-ai/spec-first.

  • SKILL.md
  • evals/cases/bug-request-routes-debug.yaml
  • evals/cases/docs-only-no-yield.yaml
  • evals/cases/r2-elegant-refactor.yaml
  • evals/cases/safety-check-preserved.yaml
  • evals/eval.yaml
  • evals/fixtures/repos/mini-ledger-guarded/README.md
  • evals/fixtures/repos/mini-ledger-guarded/package.json
  • evals/fixtures/repos/mini-ledger-guarded/src/server.js
  • evals/fixtures/repos/mini-ledger/README.md
  • evals/fixtures/repos/mini-ledger/package.json
  • evals/fixtures/repos/mini-ledger/src/server.js
  • evals/fixtures/scripts
  • … and 9 more

Open the folder on GitHubat commit 74655dc

Compare with similar skills

Spec Simplify Code next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Spec Simplify Code compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Spec Simplify Code this skillleo-kuang-ai/spec-first107—~2.4kAutomated safety check: PassMIT
Reviewtisfeng/Easydict15k—~659Automated safety check: PassGPL-3.0
Disciplined Worktree Promotionnathanmcnulty/nathanmcnulty441—~2.1kAutomated safety check: PassUnlicense
Absolute Simplifymaddhruv/absolute218—~6.1kAutomated safety check: PassMIT
Pragmatic Reviewheyitsnoah/claudesidian2.6k—~2.6kAutomated safety check: PassMIT
Code SimplifierTwiTech-LAB/devchain101—~2kAutomated safety check: PassCustom licence

Similar skills

  • Review

    tisfeng/Easydict

    审查本地工作树、提交、range、文件或模块,找出有证据的缺陷。GitHub PR 审查使用 review-pr;代码清理使用 code-simplifier。

    15k GitHub stars~659 tokensUpdated 2 days ago
    DevelopmentAuto-check passed
  • Disciplined Worktree Promotion

    nathanmcnulty/nathanmcnulty

    Guides agents working in isolated git worktrees or short-lived branches on what to keep, discard or promote, so the accepted baseline branch stays clean.

    441 GitHub stars~2.1k tokensUpdated 18 days ago
    DevelopmentAuto-check passed
  • Absolute Simplify

    maddhruv/absolute

    A skill your agent uses when the user wants to simplify, clean up, refactor, tidy, or refine code — their staged/unstaged git changes or a target file/path.

    218 GitHub stars~6.1k tokensUpdated 3 mo ago
    DevelopmentAuto-check passed
  • Pragmatic Review

    heyitsnoah/claudesidian

    Interactive pragmatic code review focusing on YAGNI and KISS principles.

    2.6k GitHub stars~2.6k tokensUpdated 5 mo ago
    DevelopmentAuto-check passed
  • Code Simplifier

    TwiTech-LAB/devchain

    Review a change set for reuse, simplification, efficiency, and altitude problems, then apply the fixes while preserving exact behavior.

    101 GitHub stars~2k tokensUpdated yesterday
    DevelopmentAuto-check passed
  • Code Refiner

    Mathews-Tom/armory

    Deep code simplification and refactoring preserving behavior across Python, Go, TypeScript, Rust.

    328 GitHub stars~3.1k tokensUpdated 2 days ago
    DevelopmentAuto-check passed

More from leo-kuang-ai/spec-first

All 35 skills in this repo
  • Spec App Consistency Audit

    leo-kuang-ai/spec-first

    Audit mobile App PRD/Figma/local-source consistency across page routes, KMP/Clean Architecture, components, analytics, i18n, engineering quality, and industry lenses before runtime validation; use…

    107 GitHub stars~4.6k tokensUpdated 14 days ago
    Auto-check passed
  • Spec Handoff

    leo-kuang-ai/spec-first

    Create a durable cross-session handoff or resume from a user-selected continuity source.

    107 GitHub stars~1.8k tokensUpdated 14 days ago
    Auto-check passed
  • Spec Pov

    leo-kuang-ai/spec-first

    Give a decisive, project-grounded verdict on an external input — judged against the current project, not in the abstract.

    107 GitHub stars~4.5k tokensUpdated 14 days ago
    Auto-check passed
  • Spec Resolve PR Feedback

    leo-kuang-ai/spec-first

    Resolve PR review feedback by evaluating validity and fixing issues with conflict-aware resolver dispatch.

    107 GitHub stars~1.8k tokensUpdated 14 days ago
    Auto-check: notes
  • Spec Riffrec Feedback Analysis

    leo-kuang-ai/spec-first

    Analyze explicit Riffrec product-feedback captures, including riffrec-.zip, the Riffrec session.json + events.json + recording.webm + voice.webm bundle, or media/notes the user identifies as a…

    107 GitHub stars~1.4k tokensUpdated 14 days ago
    Auto-check passed
  • Spec Compound

    leo-kuang-ai/spec-first

    Document a recently solved problem or durable project vocabulary in docs/solutions/ or CONCEPTS.md.

    107 GitHub stars~18k tokensUpdated 14 days ago
    Auto-check passed

Works with

Categories

Questions about Spec Simplify Code

What does Spec Simplify Code do?

Simplify recently changed code for clarity, reuse, quality, and efficiency while preserving behavior. Spec Simplify Code is an agent skill from leo-kuang-ai/spec-first. Simplify recently changed code for clarity, reuse, quality, and efficiency while preserving behavior.

When should I use Spec Simplify Code?

Spec Simplify Code fits situations like: tidy/refactor passes; use spec-debug for bugs.

How do I install Spec Simplify Code in Claude Code?

Run `npx skills add leo-kuang-ai/spec-first --skill spec-simplify-code -a claude-code`. Or copy the skill folder (skills/spec-simplify-code in leo-kuang-ai/spec-first) into .claude/skills/spec-simplify-code in your project. Claude Code loads it when a task matches its description.

How do I install Spec Simplify Code in Codex?

Run `npx skills add leo-kuang-ai/spec-first --skill spec-simplify-code -a codex`. Or copy the skill folder (skills/spec-simplify-code in leo-kuang-ai/spec-first) into .agents/skills/spec-simplify-code in your project. Codex loads it when a task matches its description.

Can I use Spec Simplify Code in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add leo-kuang-ai/spec-first --skill spec-simplify-code -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/spec-simplify-code, .gemini/skills/spec-simplify-code, .github/skills/spec-simplify-code and .opencode/skills/spec-simplify-code in your project.

What does Spec Simplify Code need to run?

Going by SKILL.md and its folder, Spec Simplify Code needs JavaScript for the scripts in its folder and the command-line tools its instructions call (git). Our summary lists: Node.js.

Does Spec Simplify Code access the network?

SKILL.md contains no URLs. Its commands use git, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Spec Simplify Code safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Spec Simplify Code use?

Spec Simplify Code is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Spec Simplify Code use?

About 2.4k tokens (SKILL.md is roughly 9.4k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 1.6k tokens, read only when the agent opens those files.

What are the alternatives to Spec Simplify Code?

Skills that share tags, products or a category with Spec Simplify Code: Review (tisfeng/Easydict, 15k stars), Disciplined Worktree Promotion (nathanmcnulty/nathanmcnulty, 441 stars), Absolute Simplify (maddhruv/absolute, 218 stars) and Pragmatic Review (heyitsnoah/claudesidian, 2.6k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Spec Simplify Code?

leo-kuang-ai (a GitHub user) maintains it in leo-kuang-ai/spec-first, which has 107 GitHub stars. The repository holds 35 skills in this directory. The repository was last updated on September 24, 2026.

Source: leo-kuang-ai/spec-first on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.