Code simplifier

Simplifies recently changed code without changing behaviour: less nesting, no nested ternaries, clearer names, no redundant abstractions, while following CLAUDE.md conventions. Use when code works but reads heavier than it should and needs a cleanup pass.

CodingPack: Sentry skills119 linescode-simplifier
Author
Source
getsentry/skills/skills/code-simplifier @ a582c51
License
Apache-2.0 · Copyright 2025 Functional Software, Inc. dba Sentry

About this skill

What it does

The skill tidies code that already works without changing what it does. An HTML comment says it is based on Anthropic's code-simplifier agent for Claude Code, and it keeps that agent's persona and five principles: identical behaviour; the project's standards from CLAUDE.md; clarity over brevity (less nesting, no redundant code or abstractions, clearer names, no comments that restate the code, no nested ternaries); no over-simplifying into dense one-liners or merged concerns; and only code changed in the current session unless you widen the scope.

Six steps follow, from finding the recently modified sections to documenting only changes that affect understanding. Three TypeScript before-and-after examples: a nested ternary turned into an if chain, a filter/map/reduce chain split into named steps, a one-line helper replaced by the direct check.

The standards under "Apply Project Standards" are specific: ES modules with sorted imports and extensions, function over arrow functions, explicit return types on top-level functions, explicit Props types for React components, avoiding try/catch where possible. SKILL.md presents them as the CLAUDE.md standards, so they arrive with the skill whether or not your CLAUDE.md has them. The folder holds only SKILL.md and the licence.

When to use it, and when not

Use it right after a feature works, as a cleanup pass over what you or the agent just changed.

If your codebase prefers arrow functions or skips return types, say so in the request. The skill names no test run, so ask for one if you want behaviour checked rather than assumed.

How to run it

The install command below puts the folder in place. The agent picks the skill up by its description when you ask to simplify or clean up code; to call it yourself:

  • Claude Code: /code-simplifier, or ask for the skill by name.
  • Codex: $code-simplifier.
  • Cursor: type / in the Agent chat and pick code-simplifier.

Example: /code-simplifier Clean up what we changed in src/checkout this session, keep our arrow functions, and run the tests afterwards.

How it differs from similar skills

Code simplification grew from the same Anthropic agent but adds a working method: learn why the code is the way it is, simplify one step at a time with tests after each, revert on red. Pick it for that discipline and this skill for a short pass. Safe refactoring covers larger restructuring and writes characterization tests first. Code comments cleanup touches comments only.

Install

Run one command — it saves SKILL.md and the files it uses into your agent's skills folder. Claude Code and Codex pick up a new skill without a restart; if it does not show up, restart the agent.

Claude Code — macOS, Linux
curl -fsSL --create-dirs -o ~/.claude/skills/code-simplifier/SKILL.md https://anymodel.org/en/skills/sentry/code-simplifier/SKILL.md -o ~/.claude/skills/code-simplifier/LICENSE https://anymodel.org/en/skills/sentry/code-simplifier/LICENSE
Codex, Cursor — macOS, Linux
curl -fsSL --create-dirs -o ~/.agents/skills/code-simplifier/SKILL.md https://anymodel.org/en/skills/sentry/code-simplifier/SKILL.md -o ~/.agents/skills/code-simplifier/LICENSE https://anymodel.org/en/skills/sentry/code-simplifier/LICENSE
Claude Code — Windows PowerShell
foreach ($f in 'SKILL.md','LICENSE') { $p = Join-Path "$HOME\.claude\skills\code-simplifier" $f; New-Item -ItemType Directory -Force (Split-Path $p) | Out-Null; Invoke-WebRequest "https://anymodel.org/en/skills/sentry/code-simplifier/$f" -UseBasicParsing -OutFile $p }
Codex, Cursor — Windows PowerShell
foreach ($f in 'SKILL.md','LICENSE') { $p = Join-Path "$HOME\.agents\skills\code-simplifier" $f; New-Item -ItemType Directory -Force (Split-Path $p) | Out-Null; Invoke-WebRequest "https://anymodel.org/en/skills/sentry/code-simplifier/$f" -UseBasicParsing -OutFile $p }

Any other agent: save the file into its skills folder, or give it the link to the file: https://anymodel.org/en/skills/sentry/code-simplifier/SKILL.md

SKILL.md

Raw

<!-- Based on Anthropic's code-simplifier agent: https://github.com/anthropics/claude-plugins-official/blob/main/plugins/code-simplifier/agents/code-simplifier.md -->

Code Simplifier

You are an expert code simplification specialist focused on enhancing code clarity, consistency, and maintainability while preserving exact functionality. Your expertise lies in applying project-specific best practices to simplify and improve code without altering its behavior. You prioritize readable, explicit code over overly compact solutions.

Refinement Principles

1. Preserve Functionality

Never change what the code does - only how it does it. All original features, outputs, and behaviors must remain intact.

2. Apply Project Standards

Follow the established coding standards from CLAUDE.md including:

  • Use ES modules with proper import sorting and extensions
  • Prefer function keyword over arrow functions
  • Use explicit return type annotations for top-level functions
  • Follow proper React component patterns with explicit Props types
  • Use proper error handling patterns (avoid try/catch when possible)
  • Maintain consistent naming conventions

3. Enhance Clarity

Simplify code structure by:

  • Reducing unnecessary complexity and nesting
  • Eliminating redundant code and abstractions
  • Improving readability through clear variable and function names
  • Consolidating related logic
  • Removing unnecessary comments that describe obvious code
  • Avoiding nested ternary operators - prefer switch statements or if/else chains for multiple conditions
  • Choosing clarity over brevity - explicit code is often better than overly compact code

4. Maintain Balance

Avoid over-simplification that could:

  • Reduce code clarity or maintainability
  • Create overly clever solutions that are hard to understand
  • Combine too many concerns into single functions or components
  • Remove helpful abstractions that improve code organization
  • Prioritize "fewer lines" over readability (e.g., nested ternaries, dense one-liners)
  • Make the code harder to debug or extend

5. Focus Scope

Only refine code that has been recently modified or touched in the current session, unless explicitly instructed to review a broader scope.

Refinement Process

  1. Identify the recently modified code sections
  2. Analyze for opportunities to improve elegance and consistency
  3. Apply project-specific best practices and coding standards
  4. Ensure all functionality remains unchanged
  5. Verify the refined code is simpler and more maintainable
  6. Document only significant changes that affect understanding

Examples

Before: Nested Ternaries

const status = isLoading ? 'loading' : hasError ? 'error' : isComplete ? 'complete' : 'idle';

After: Clear Switch Statement

function getStatus(isLoading: boolean, hasError: boolean, isComplete: boolean): string {
  if (isLoading) return 'loading';
  if (hasError) return 'error';
  if (isComplete) return 'complete';
  return 'idle';
}

Before: Overly Compact

const result = arr.filter(x => x > 0).map(x => x * 2).reduce((a, b) => a + b, 0);

After: Clear Steps

const positiveNumbers = arr.filter(x => x > 0);
const doubled = positiveNumbers.map(x => x * 2);
const sum = doubled.reduce((a, b) => a + b, 0);

Before: Redundant Abstraction

function isNotEmpty(arr: unknown[]): boolean {
  return arr.length > 0;
}

if (isNotEmpty(items)) {
  // ...
}

After: Direct Check

if (items.length > 0) {
  // ...
}

Connect through AnyModel API

This skill runs on whatever model your agent uses. Point Claude Code, Codex or Cursor at AnyModel to run it on Claude, GPT, Gemini and more with one key — pay per token, no subscription.

More from the pack Sentry skills

AGENTS.md and CLAUDE.md writer

Writes or trims a repository's AGENTS.md to under 60 lines of commands, conventions and pointers to existing docs, checks every path, and makes CLAUDE.md a symlink to it. Use when a repo needs agent instructions or its current file has grown long or stale.

Claude Code settings audit

Detects a repository's stack and proposes a Claude Code settings.json allow list of read-only commands for the tools it actually uses, plus docs domains and Sentry or Linear MCP entries. Use when setting up Claude Code permissions or auditing existing ones.

Code review, Sentry practices

Reviews a change by Sentry's guidelines: runtime errors, performance and N+1 queries, side effects, compatibility, security, design and tests, with a polite tone and approval once only minor issues remain. Use when reviewing a pull request or branch.

Conventional commit messages

Commits in Sentry's Conventional Commits style: a feature branch instead of main, a typed capitalised subject up to 70 characters, Fixes or Refs footers, no personal data. Use when asked to commit changes or draft a commit message.

Django access control review

Audits Django and DRF code for IDOR and broken access control by learning the app's authorization model and tracing each endpoint from ID to query, reporting only confirmed gaps with enforcing fixes. Use when reviewing views, viewsets or tenant isolation.

Find bugs in branch changes

Reviews the commits on the current branch for security holes, bugs and quality issues with an eleven-item checklist and reports verified findings with file, line, severity and fix, without editing code. Use when you want a security-first pass before a PR.

GitHub Actions security review

Audits GitHub Actions workflows for attacks an outsider without write access can run: pwn requests, expression injection, comment commands, token theft, poisoned agent configs, unpinned actions. Use when reviewing CI security or changing workflows.

Iterate a PR until CI is green

Drives an open PR to green: fixes failing CI and high and medium review comments, verifies locally, commits, pushes and repeats, stopping at human approval or draft gates. Use when a PR is red or has review feedback to work through.

PR title and description writer

Writes or refreshes a PR title in Sentry's conventional format and a short reviewer-facing description without template headings or test logs, then opens a draft or updates the PR. Use when opening a PR or after commits change its scope.

Prompt optimizer

Writes, repairs or ports system and agent prompts against a small eval set, comparing candidate rewrites on the same cases and checking the winner on held-out ones. Use when a prompt is unreliable, moves to another model family or needs evals.

Secret leaks through serialization

Finds secrets that leak when a credential field on a dataclass, pydantic model or JS object meets code that logs or traces whole objects, searching the whole repository for the other half. Use when a change adds such a field or a wholesale sink.

SECURITY_MODEL.md for review tools

Writes and maintains SECURITY_MODEL.md, telling security review tools a repository's exposure, invariants, reportable finding classes and owner-confirmed exclusions, with a script that flags stale references. Use when preparing a repo for automated review.

Agent skill security scanner

Audits an agent skill before installation: a static scan for prompt injection, hidden Unicode, secrets, risky scripts and structural traps, then a review of intent and permissions ending in a verdict. Use when a skill comes from an outside source.

Skill writer by the Agent Skills spec

Creates and improves agent skills by Sentry's workflow: sources with provenance, the simplest execution shape, SPEC.md and SOURCES.md, precision passes after each change and a structural validator. Use when building a skill that a team will maintain.

Security review, Sentry

Reviews a file, diff or component for exploitable vulnerabilities with OWASP-based references, researches the codebase before flagging and reports only findings reached by attacker-controlled input. Use when a change needs a low-noise security review.

Django performance review

Reviews Django and DRF code for N+1 queries, unbounded querysets, missing indexes and write loops, validating table size and hot paths before reporting. Use when a Django view or endpoint is slow or a change touches large tables.