code-simplification

A code-review and refactoring guide for making working code easier to read and maintain without changing what it does.

In plain words
What is it for?
Use it when functions are too large, conditions are deeply nested, names are vague, or the same logic appears in several places.
Why use it?
It helps remove unnecessary complexity while checking why existing safeguards and design choices are present first.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/jmxt3/gitscape.ai/code-simplification
Any agent
npx skills add jmxt3/gitscape.ai --skill code-simplification
Clone the repo
git clone --depth 1 https://github.com/jmxt3/gitscape.ai

Made for: Claude Code, Codex.

Per session 51 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,635 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00051 $0.01635
Opus 5 $0.00026 $0.00817
Sonnet 5 $0.00010 $0.00327
Haiku 4.5 $0.00005 $0.00163

Measured 2d ago against content hash f4cdfd29edb0, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

code-simplification scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.agents/skills/code-simplification/SKILL.md · 219 lines

How it starts

The opening of the file, as written. The whole thing — 219 lines — stays where its author put it; the contents beside it link to each section on GitHub.

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()

Read the full file on GitHub · 219 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 219 lines · 51 tokens per session scan A f4cdfd29edb0

Subscribe to this mod's changes

code-simplification is a skill published in the GitHub repository jmxt3/gitscape.ai (33 stars, last pushed 1mo ago), licensed Apache-2.0. It adds 51 tokens to every session and 1,635 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

issue-triage

Issue triage: audit open issues, categorize, detect duplicates, cross-ref PRs, risk assessment, post comments. Args: "all" for deep analysis of all, issue numbers to focus (e.g. "42 57"), "en"/"fr" for language, no arg = audit only in French.

rtk-ai/rtk · 70 tokens

issue

Use when starting a chain from a GitHub issue — turning an issue URL or number into a triaged, planned, dispatched, and reviewed pull request. Classifies the thread (bug → root-cause discipline, feature → plan chain, question → drafted reply), synthesizes a spec from the issue's own acceptance criteria, then runs the…

jeremylongshore/tons-of-skills-marketplace · 115 tokens

github-secret-hunting

Find leaked API keys, tokens, and credentials in public GitHub repositories.

uphiago/recon-skills · 20 tokens

toolset-design

Design and validate new MCP toolsets, tools, and tool changes. Use when planning a new toolset, adding tools to an existing toolset, reviewing a toolset PR, or deciding whether a new tool is warranted. Covers the full lifecycle: eval-first validation, tool design methodology, consolidation patterns, and review…

containers/kubernetes-mcp-server · 69 tokens

github

GitHub operations via gh CLI: issues, PRs, CI runs, code review, API queries.

AIOSAI/AIPass · 23 tokens

a11y-remediate

Use to produce a leader-facing remediation proposal from one or more /a11y-audit outputs plus team and product context. Translates audit findings into sprint plans, staffing asks, customer-facing language, compliance rollups, and critical-path analysis. Refuses to fabricate numbers, owners, or commitments beyond the…

gitkraken/vscode-gitlens · 72 tokens