| name | code-simplifier | ||||||
|---|---|---|---|---|---|---|---|
| displayName | Code Simplifier | ||||||
| description | Simplifies and refines code across frameworks for clarity, consistency, and maintainability while preserving all functionality. Adapts to your framework with up-to-date best practices. | ||||||
| keywords |
|
||||||
| author | Raishin |
Code Simplifier is a comprehensive guide for enhancing code clarity, consistency, and maintainability across multiple programming languages and frameworks. It provides framework-specific best practices while maintaining core principles that apply universally.
This power helps you:
- Preserve Functionality: Simplify code without changing what it does
- Enhance Clarity: Make code more readable and maintainable
- Apply Standards: Follow framework-specific conventions and best practices
- Maintain Balance: Avoid over-simplification that reduces clarity
- Stay Current: Access up-to-date framework documentation via Context7 MCP
Whether you're working with C, C#, Java, Kotlin, Rust, TypeScript/React, JavaScript, Python, PHP/Laravel/Symfony, Spring Boot, or other languages and frameworks, this power provides targeted guidance for writing cleaner, more maintainable code.
This power includes language and framework-specific guides that you can access on-demand:
- core - Universal code simplification principles that apply to all languages and frameworks
- c - C code simplification patterns, memory management, and best practices
- csharp - C# patterns with LINQ, async/await, and .NET conventions
- java - Java modern features, streams, lambdas, and design patterns
- js - JavaScript simplification techniques and modern ES6+ features
- kotlin - Kotlin null safety, coroutines, and idiomatic patterns
- python - Python code clarity and Pythonic patterns
- rust - Rust idioms, ownership patterns, and error handling
- typescript - TypeScript type system, generics, and React patterns
- java-spring - Spring Boot dependency injection, REST APIs, and JPA patterns
- php - PHP-specific simplification patterns and best practices
- php-laravel - Laravel framework conventions and elegant patterns
- php-symfony - Symfony framework best practices and standards
- python-django - Django models, views, QuerySet optimization, and patterns
- python-fastapi - FastAPI async patterns, Pydantic, and dependency injection
- python-fastmcp - FastMCP server patterns, tools, and resource management
- python-flask - Flask blueprints, application factory, and SQLAlchemy patterns
To access a specific guide:
Call action "readSteering" with powerName="code-simplifier", steeringFile="{language}.md"
These principles apply across all frameworks and languages:
Never change what the code does - only how it does it.
- All original features, outputs, and behaviors must remain intact
- Refactoring should be behavior-preserving transformations
- Test coverage should remain the same or improve
Make code easier to understand and maintain.
- Reduce unnecessary complexity and nesting
- Eliminate redundant code and abstractions
- Use clear, descriptive names for variables and functions
- Consolidate related logic
- Remove comments that describe obvious code
- Avoid nested ternary operators - prefer explicit conditionals
Follow established conventions and best practices.
- Use framework-specific patterns and idioms
- Follow community-accepted coding standards
- Leverage framework features appropriately
- Maintain consistent naming conventions
Avoid over-simplification that reduces clarity.
- Don't sacrifice readability for brevity
- Keep helpful abstractions that improve organization
- Avoid overly clever solutions
- Don't combine too many concerns into single units
- Explicit code is often better than compact code
Prioritize recently modified code.
- Review code that has been recently changed
- Expand scope only when explicitly requested
- Consider the context of surrounding code
This power uses Context7 MCP to provide up-to-date documentation for frameworks and libraries:
- resolve-library-id: Find the correct library identifier for documentation lookup
- query-docs: Query up-to-date documentation and code examples for any framework
When simplifying Laravel code, you can query for current best practices:
1. Resolve library: resolve-library-id with libraryName="laravel"
2. Query docs: query-docs with libraryId="/laravel/docs" and query="eloquent relationship best practices"
This ensures your simplifications follow the latest framework conventions.
This power includes two agent hooks to automate code simplification:
Location: hooks/simplify-on-demand.json
Type: User-triggered hook (manual)
Purpose: Manually trigger code review when you want feedback on your code
How to use:
- Open the Agent Hooks panel in Kiro (View → Agent Hooks)
- Find "Simplify Code On-Demand" in the hooks list
- Click the trigger button when you want a code review
- The agent will review your current or recently modified files
What it reviews:
- Unnecessary complexity and nesting
- Variable and function naming
- Code duplication
- Framework convention adherence
- Overall readability
Location: hooks/simplify-on-save.json
Type: File-edited hook (automatic)
Status:
Purpose: Automatically review code every time you save a file
Why disabled by default: Automatic reviews can interrupt your workflow. Enable this only if you want continuous feedback.
How to enable:
- Open the Agent Hooks panel in Kiro
- Find "Simplify Code On Save (Disabled by Default)"
- Click to enable the hook
- Now every file save will trigger a quick code review
Supported file types:
- JavaScript/TypeScript:
.js,.ts,.jsx,.tsx - Python:
.py - Java/Kotlin:
.java,.kt - Rust:
.rs - C/C++:
.c,.cpp - C#:
.cs - PHP:
.php
What it does:
- Provides brief, actionable feedback (2-3 suggestions max)
- Acknowledges when code is already clean
- Focuses on significant improvements only
To disable: Return to Agent Hooks panel and disable the hook
Goal: Manually trigger code simplification review for current or recently modified files
Using the Hook:
- Open the Agent Hooks panel in Kiro
- Find "Simplify Code On-Demand" hook
- Click the trigger button when you want a code review
- The agent will review your code and provide specific suggestions
Manual Workflow (without hook):
- Identify the recently modified code sections
- Read the appropriate framework steering file for specific guidance
- Analyze for opportunities to improve clarity and consistency
- Apply framework-specific best practices
- Verify functionality remains unchanged
- Document significant changes if needed
Example:
User: "I just modified the UserController, can you simplify it?"
Agent:
1. Read the modified UserController code
2. Call readSteering with steeringFile="php-laravel.md"
3. Apply Laravel-specific simplification patterns
4. Suggest improvements while preserving functionality
Goal: Automatically review code for simplification opportunities when saving files
To Enable:
- Open the Agent Hooks panel in Kiro
- Find "Simplify Code On Save (Disabled by Default)" hook
- Click to enable the hook
- Now every time you save a code file, it will be automatically reviewed
What it does:
- Monitors file saves for common code file extensions
- Provides quick, actionable feedback on simplification opportunities
- Keeps reviews brief (2-3 suggestions max)
- Acknowledges when code is already clean
To Disable:
- Return to Agent Hooks panel and disable the hook
Goal: Apply framework-specific patterns to existing code
Steps:
- Determine the framework being used
- Load the appropriate steering file
- Query Context7 for current framework best practices (if needed)
- Apply framework-specific simplification patterns
- Ensure code follows framework conventions
Example:
User: "Refactor this Python function to be more Pythonic"
Agent:
1. Call readSteering with steeringFile="python.md"
2. Apply Python-specific patterns (list comprehensions, context managers, etc.)
3. Ensure PEP 8 compliance
4. Suggest idiomatic Python improvements
Goal: Review code across multiple files and frameworks
Steps:
- Read the core principles (core.md)
- For each file, load the appropriate framework steering file
- Apply universal principles + framework-specific patterns
- Ensure consistency across the codebase
✅ Do simplify when:
- Code has unnecessary nesting or complexity
- Variable/function names are unclear
- Logic is duplicated across multiple places
- Framework conventions are not being followed
- Code is harder to understand than necessary
❌ Don't simplify when:
- The code is already clear and maintainable
- Simplification would reduce readability
- The complexity is inherent to the problem domain
- Existing abstractions serve a clear purpose
Reduce Nesting:
// Before
if ($user) {
if ($user->isActive()) {
if ($user->hasPermission('edit')) {
// do something
}
}
}
// After
if (!$user || !$user->isActive() || !$user->hasPermission('edit')) {
return;
}
// do somethingAvoid Nested Ternaries:
// Bad - nested ternary
const status = user ? user.active ? user.verified ? 'full' : 'partial' : 'inactive' : 'guest';
// Good - explicit conditions
let status = 'guest';
if (user) {
if (user.active) {
status = user.verified ? 'full' : 'partial';
} else {
status = 'inactive';
}
}
// Better - match/switch when available
const status = match(true) {
!user => 'guest',
!user.active => 'inactive',
user.verified => 'full',
default => 'partial'
};Clear Naming:
# Before
def proc(d):
return [x for x in d if x > 0]
# After
def filter_positive_numbers(numbers):
return [num for num in numbers if num > 0]Problem: Cannot query framework documentation Symptoms:
- Error: "MCP server not responding"
- resolve-library-id or query-docs fails
Solutions:
- Verify Context7 API key is set in mcp.json
- Check internet connection
- Restart Kiro to reconnect MCP server
- Verify Context7 MCP server is not disabled
Problem: Agent doesn't apply correct framework patterns Symptoms:
- Generic suggestions instead of framework-specific
- Wrong conventions being applied
Solutions:
- Explicitly specify the framework in your request
- Ensure the appropriate steering file exists
- Check that file extensions match expected patterns (.php, .js, .py)
Problem: Suggested changes reduce code clarity Symptoms:
- Code becomes harder to understand
- Helpful abstractions are removed
- Too much logic combined into single units
Solutions:
- Review the "Maintain Balance" principle in core.md
- Provide feedback: "This is too compact, keep it more explicit"
- Request specific aspects to preserve: "Keep the service layer separation"
The Context7 MCP server requires an API key:
- CONTEXT7_API_KEY: Your Context7 API key for accessing documentation
- Visit: https://context7.com
- Sign up for an account
- Navigate to API Keys section
- Generate a new API key
- Add it to your mcp.json configuration
IMPORTANT: Before using this power, replace the
following placeholder in mcp.json:
YOUR_CONTEXT7_API_KEY: Your Context7 API key for accessing up-to-date framework documentation.- How to get it:
- Go to https://context7.com
- Sign up or log in to your account
- Navigate to Settings → API Keys
- Click "Generate New API Key"
- Copy the API key
- Replace
YOUR_CONTEXT7_API_KEYin mcp.json with your actual key
- How to get it:
After replacing the placeholder, your mcp.json should look like:
{
"mcpServers": {
"context7": {
"command": "npx",
"args": [
"-y",
"@upstash/context7-mcp",
"--api-key",
"ctx7_your_actual_key_here"
],
"env": {},
"disabled": false,
"autoApprove": [
"resolve-library-id",
"query-docs"
]
}
}
}Package: @upstash/context7-mcp MCP Server:
context7