# python-code-simplifier

python-code-simplifier refines recently modified Python code for clarity and maintainability without altering existing program logic or outputs.

- subagent · `type=agent` · Claude Code, Codex, Cursor · ★ 540 repo stars
- Author: Anthropic
- License: CC-BY-SA-4.0 · policy=link-only · description only; the file stays with the author
- Source: https://github.com/trailofbits/skills-curated/tree/HEAD/plugins/python-code-simplifier/agents/python-code-simplifier.md
- Updated: 2026-07-14
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/agents/python-code-simplifier

## What it does

Operating on the `opus` model, this subagent inspects freshly edited Python files to streamline their structure. It unrolls deeply nested conditionals with guard clauses and adds type annotations across public signatures.

Readability takes priority over short one-liners. The agent avoids syntax tricks like overloaded walrus operators or dense comprehensions. Unless you explicitly ask for a wider pass, changes stay confined to code touched in the current session.

## Install

### Claude Code (native platform)

1. **Plugin marketplace**
In the agent chat (not a shell):
```text
/plugin marketplace add trailofbits/skills-curated
```
In the agent chat (not a shell):
```text
/plugin install python-code-simplifier@skills-curated
```

2. **Manually: put the files in place**
- File: `.claude/agents/python-code-simplifier.md` — For all projects use ~/.claude/agents/. Claude delegates by the description field or an @-mention

### Codex

**Manually: put the files in place**
- File: `.codex/agents/python-code-simplifier.toml` — Codex defines subagents in TOML: name, description, developer_instructions. Move the Markdown text into developer_instructions by hand. For all projects use ~/.codex/agents/

### Cursor

**Manually: put the files in place**
- File: `.cursor/agents/python-code-simplifier.md` — Cursor also reads .claude/agents/

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/trailofbits/skills-curated/tree/HEAD/plugins/python-code-simplifier/agents/python-code-simplifier.md

## When to use it
- flatten nested conditional branches using early returns
- apply type hints across public functions and return values
- organize absolute imports into clean standard library and local tiers
- replace complex lambda expressions with explicit function definitions

## Example prompts
- Review the latest changes in `services/auth.py` and simplify nested logic.
- Clean up recent edits in the current session and add missing type annotations.
- Flatten the condition checks in our API route handler using guard clauses.

## Similar
- [python-design-patterns](https://affpapa.org/en/nevibecode/skills/python-design-patterns.md) — skill · 22842 installs
- [python-anti-patterns](https://affpapa.org/en/nevibecode/skills/python-anti-patterns.md) — skill · 13278 installs
- [code-simplifier](https://affpapa.org/en/nevibecode/skills/rtk-ai-code-simplifier.md) — skill · 2300 installs
- [python-best-practices](https://affpapa.org/en/nevibecode/skills/python-best-practices.md) — skill · 871 installs
- [python-expert-best-practices-code-review](https://affpapa.org/en/nevibecode/skills/python-expert-best-practices-code-review.md) — skill · 692 installs
- [python](https://affpapa.org/en/nevibecode/skills/pproenca-python.md) — skill · 329 installs

From the same set: [trailofbits/skills-curated](https://affpapa.org/en/nevibecode/by/trailofbits/skills-curated.md) — 51 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
