
python-code-simplifier
Python refactoring agent that simplifies recent code while keeping behavior identical.
- version
- 1.0.0
- GitHub stars
- 537
What it does
- Adds a
python-code-simplifieragent that reviews and refines recently modified Python files on request - Flattens nesting with guard clauses and early returns, and removes redundant code and unnecessary comments
- Enforces naming conventions:
snake_casefunctions,PascalCaseclasses, andUPPER_SNAKE_CASEconstants - Adds type annotations to public signatures, sorts imports into stdlib, third-party, and local groups
Simplifies and refines Python code for clarity, consistency, and maintainability while preserving all functionality.
Add marketplace
/plugin marketplace add trailofbits/skills-curatedRun it inside Claude Code once, then install the plugin below.
Install
/plugin install python-code-simplifier@skills-curatedRun it inside Claude Code after adding the marketplace.
Files
Discovered from sourceYou are an expert Python code simplification specialist focused on enhancing code clarity, consistency, and maintainability while preserving exact functionality. Your expertise lies in applying Python best practices to simplify and improve code without altering its behavior. You prioritize readable, explicit code over overly compact solutions.
You will analyze recently modified code and apply refinements that:
-
Preserve Functionality: Never change what the code does - only how it does it. All original features, outputs, and behaviors must remain intact.
-
Apply Python Standards: Follow established Python coding standards including:
- Use absolute imports with proper sorting (stdlib first, then third-party, then local)
- Prefer explicit function definitions over lambdas for non-trivial logic
- Use type annotations on public function signatures and return types
- Follow proper class patterns with clear
__init__, explicit attributes, and dataclasses where appropriate - Use structured error handling — prefer early returns and guard clauses over deeply nested try/except
- Maintain consistent naming:
snake_casefor functions and variables,PascalCasefor classes,UPPER_SNAKE_CASEfor constants
-
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
- Preferring early returns over deep nesting — flatten conditional chains with guard clauses
- Choosing clarity over brevity — explicit code is often better than overly compact comprehensions or chained expressions
-
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 classes
- Remove helpful abstractions that improve code organization
- Prioritize "fewer lines" over readability (e.g., dense comprehensions, excessive unpacking, overloaded walrus operators)
- Make the code harder to debug or extend
-
Focus Scope: Only refine code that has been recently modified or touched in the current session, unless explicitly instructed to review a broader scope.
Your refinement process:
- Identify the recently modified code sections
- Analyze for opportunities to improve clarity and consistency
- Apply Python best practices and coding standards
- Ensure all functionality remains unchanged
- Verify the refined code is simpler and more maintainable
- Document only significant changes that affect understanding
You operate autonomously and proactively, refining code immediately after it's written or modified without requiring explicit requests. Your goal is to ensure all code meets the highest standards of clarity and maintainability while preserving its complete functionality.
Readme
Python Code Simplifier
Simplifies and refines Python code for clarity, consistency, and maintainability while preserving all functionality. Focuses on recently modified code unless instructed otherwise.
Adapted from Anthropic's code-simplifier agent with Python-specific standards replacing the original TypeScript/React guidance.
Install
/plugin install trailofbits/skills-curated/plugins/python-code-simplifier
What It Does
After writing or modifying Python code, this skill reviews recent changes and applies refinements:
- Flattens unnecessary nesting with guard clauses and early returns
- Improves naming consistency (
snake_casefunctions,PascalCaseclasses,UPPER_SNAKE_CASEconstants) - Adds type annotations to public function signatures
- Sorts imports (stdlib, third-party, local)
- Replaces dense comprehensions or chained expressions with clearer alternatives
- Removes redundant code and unnecessary comments
- Consolidates related logic without over-abstracting
All changes preserve exact functionality — only how the code reads changes, never what it does.
Credits
- Source: anthropics/claude-plugins-official
- Author: Anthropic
- Adaptation: TypeScript/React standards replaced with Python equivalents
- License: Not specified
Details
- Marketplace
- trailofbits/skills-curated
- Source
- plugins/python-code-simplifier
- Author
- Anthropic
- Category
- Community
- Listed since
- Apr 7, 2026
More from trailofbits/skills-curated
All 29- react-pdfv1.0.0
- scv-scanv1.0.0
- security-awarenessv1.0.0
- skill-extractorv1.0.0
- wooyun-legacyv1.0.0
- x-researchv1.0.0
- ffuf-web-fuzzingv1.0.0
- ghidra-headlessv1.0.0
- humanizerv2.2.0
- last30daysv1.0.0
- openai-cloudflare-deployv1.0.0
- openai-develop-web-gamev1.0.0
- openai-docv1.0.0
- openai-gh-address-commentsv1.0.0
- openai-gh-fix-civ1.0.0
- openai-jupyter-notebookv1.0.0
- openai-netlify-deployv1.0.0
- openai-pdfv1.0.0
- openai-playwrightv1.0.0
- openai-screenshotv1.0.0
- openai-security-best-practicesv1.0.0
- openai-security-ownership-mapv1.0.0
- openai-security-threat-modelv1.0.0
- openai-sentryv1.0.0
Similar to python-code-simplifier
More Code Review & Quality
code-simplifierDennisLiuCk/claude-plugin-marketplace29 stars簡化和優化程式碼以提升清晰度、一致性和可維護性,同時保持原有功能不變
refactor-enginerohitg00/awesome-claude-code-toolkit2.8K starsExtract functions, simplify complex code, and reduce cognitive complexity
django-reviewervintasoftware/django-ai-plugins176 starsReviews and refines Django/Python code for clarity, consistency, and maintainability while preserving all functionality. Applies Django best practices, PEP 8, a
pylintTheBushidoCollective/han201 starsComprehensive Pylint skills for Python linting and code quality with configuration, checkers, and CI integration.
complexity-reducerrohitg00/awesome-claude-code-toolkit2.8K starsReduce cyclomatic complexity and simplify functions
code-review-toolsintercom/2x-skills280 starsStrict structural and architectural code review that hunts for dramatic simplifications.