Skip to content
Agentmart
Submit a tool

code-simplification

Refactoring checklist for simplifying code without changing behavior.

Skill by diego81b

IndexedAGPL-3.0★ 2
Write a review

Chalk Labs

Need help deploying code-simplification?

Chalk Labs sets up agents like this inside real teams: connected to your tools, tested on your data, with a human in the loop where it matters.

Book a call

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/diego81b-code-simplification

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

Refactoring checklist for simplifying code without changing behavior. Resolves what to simplify, how to verify behavior is preserved, and when to stop — for the REFACTOR step of implementation.

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md and code. Checked Nov 1, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/code-simplification

What's inside

Skill name
code-simplification
Description
Refactoring checklist for simplifying code without changing behavior. Resolves what to simplify, how to verify behavior is preserved, and when to stop — for the REFACTOR step of implementation.
License
AGPL-3.0
Instructions
153 lines in SKILL.md · view on GitHub

Agent Skills spec issues

  • name: missing

Files (1)

  • SKILL.md

SKILL.md (first lines)

# Code Simplification

> Inspired by the [Claude Code Simplifier plugin](https://github.com/anthropics/claude-plugins-official/blob/main/plugins/code-simplifier/agents/code-simplifier.md). Adapted here as a stack-agnostic, process-driven skill.

Shared reference for `implementer-tdd-agent` and `implementer-coder-agent`'s REFACTOR step.

Simplify code by reducing complexity while preserving exact behavior. The goal is not fewer lines — it's code that is easier to read, understand, modify, and debug. Every simplification must pass one test: would a new team member understand this faster than the original?

## When to Use

- The REFACTOR step of implementation, once tests are green (or, on the no-test-suite path, once the implementation is functionally complete)
- Code review flags readability or complexity issues
- Deeply nested logic, long functions, or unclear names surface during implementation

**When NOT to use:**

- Code is already clean — don't simplify for the sake of it
- You don't yet understand what the code does — comprehend before you simplify
- The code is performance-critical and the simpler version would be measurably slower

## The Five Principles

### 1. Preserve Behavior Exactly

Don't change what the code does — only how it expresses it. All inputs, outputs, side effects, error behavior, and edge cases must remain identical.

```
ASK BEFORE EVERY CHANGE:
- Does this produce the same output for every input?
- Does this maintain the same error behavior?
- Does this preserve the same side effects and ordering?
- Do all existing tests still pass without modification?
```

### 2. Follow Project Conventions

Simplification means making code more consistent with the codebase, not imposing external preferences. Before simplifying, read the project's own conventions and study how neighboring code handles similar patterns — import style, function declaration style, naming, error handling, type-annotation depth. Simplification that breaks project consistency is churn, not simplification.

### 3. Prefer Clarity Over Cleverness

Explicit code beats compact code when the compact version requires a mental pause to parse.

```
UNCLEAR: dense ternary chain
  const label = isNew ? 'New' : isUpdated ? 'Updated' : isArchived ? 'Archived' : 'Active'

CLEAR: readable branches
  function getStatusLabel(item) {
    if (item.isNew) return 'New'
    if (item.isUpdated) return 'Updated'
    if (item.isArchived) return 'Archived'
    return 'Active'
  }
```

### 4. Maintain Balance

Over-simplification is a real failure mode. Watch for:

- Inlining too aggressively — removing a helper that gave a concept a name makes the call site harder to read
- Combining unrelated logic — two simple functions merged into one complex function is not simpler
- Removing an abstraction that exists for extensibility or testability, not complexity
- Optimizing for line count instead of comprehension speed

### 5. Scope to What Changed

Default to simplifying recently modified code. Avoid drive-by refactors of unrelated code unless explicitly asked to broaden scope — unscoped simplification creates noise in diffs and risks unintended regressions.

## The Simplification Process

### Step 1: Understand Before Touching (Chesterton's Fence)

Before changing or removing anything, understand why it exists — if you don't understand it, you're not ready to simplify it.

```
BEFORE SIMPLIFYING, ANSWER:
- What is this code's responsibility? What calls it, what does it call?
- What are the edge cases and error paths?
- Do tests define the expected behavior?
- Why might it have been written this way — performance, platform constraint, historical reason?
```

### Step 2: Identify Simplification Opportunities

**Structural complexity:**

| Pattern | Signal | Simplification |
|---------|--------|----------------|
| Deep nesting (3+ levels) | Hard to follow control flow | Extract conditions into guard clauses — e.g. `if (data === null) throw ...; if (!data.isValid()) throw ...;` instead of nested `if/else` |
| Long functions (50+ lines) | Multiple responsibilities | Split into focused functions with descriptive names |
| Nested ternaries | Requires a mental stack to parse | Replace with if/else chains, switch, or a lookup |
| Boolean parameter flags | `doThing(true, false, true)` | Replace with an options object or separate functions |
| Repeated conditionals | Same `if` check in multiple places | Extract to a well-named predicate function |

**Naming and readability:**

| Pattern | Signal | Simplification |
|---------|--------|----------------|
| Generic names | `data`, `result`, `temp`, `val` | Rename to describe the content |
| Misleading names | A `get` function that also mutates state | Rename to reflect actual behavior |
| Comments explaining "what" | `// increment counter` above `count++` | Delete — the code is clear enough |
| Comments explaining "why" | `// retry because the API is flaky under load` | Keep — this carries intent the code can't express |

**Redundancy:**

| Pattern | Signal | Simplification |
|---------|--------|----------------|
| Duplicated logic | Same 5+ lines in multiple places | Extract to a shared function |
| Dead code | Unreachable branches, unused variables | Remove, after confirming it's truly dead |
| Unnecessary abstraction | A wrapper that adds no value | Inline it, call the underlying function directly |
| Over-engineered pattern | Factory-for-a-factory, strategy-with-one-strategy | Replace with the direct approach |

### Step 3: Apply Changes Incrementally

Make one simplification at a time; treat each as its own verified step inside the REFACTOR step, not bundled with feature or bug-fix changes in the same edit.

- **Tests cover the code** (`implementer-tdd-agent`, or `implementer-coder-agent` once its Test Decision's tests exist): re-run tests after every change. Tests fail → revert and reconsider.
- **No test covers the code** (`implementer-coder-agent` with no tests by decision): re-read the diff for behavior equivalence after every change — there is no test to catch a regression, so each change must be individually small enough to verify by inspection.

From diego81b/kairos-agents-framework, AGPL-3.0.

More from diego81b/kairos-agents-framework

Signals

Stars
2
Forks
0
Open issues
0
Last commit (this folder)
Sep 28, 2026 (1 month ago)

From GitHub (fetched Oct 24, 2026).

Details

License
AGPL-3.0
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from diego81b

Done for you

Rather not set it up yourself?

Chalk Labs scopes, builds and runs agents for your team: the task audit, the eval harness, the integrations and the weekly ops report. Fixed scope, priced before we start.

See how we build AI agents →Read the case studies

Chalk Labs is a two-founder AI and growth studio. We build AI agents, CRMs and MVPs for Web3 and AI companies, and have shipped 50+ product and token launches.

launches shipped
50+
launches shipped
media placements
500+
media placements
founders on every account
2
founders on every account

Press we've placed: Forbes · CoinDesk · Decrypt · Cointelegraph · The Block

Rahil Jain, Co-founder, Chalk Labs. Ex-Goldman Sachs engineer. You talk to the person who builds it.

Get code-simplification running in your business

Tell us what you want to automate. A founder replies within one working day with a plan, not a pitch deck.

Goes to the Chalk Labs founders, not the newsletter. Privacy

Need help deploying code-simplification?

CallGet help
Cite this page

code-simplification skill. Agent Mart. https://agentmart.dev/skills/diego81b-code-simplification (last updated 2026-10-24)