A comprehensive Kiro Power for simplifying and refining code across multiple programming languages and frameworks. Enhances code clarity, consistency, and maintainability while preserving all functionality.
Code Simplifier helps you write cleaner, more maintainable code by providing:
- Framework-specific best practices for 9+ frameworks
- Language-specific patterns for 8+ programming languages
- Up-to-date documentation via Context7 MCP integration
- Automated code review through agent hooks
- Manual on-demand reviews when you need them
- C - Memory management, pointers, and best practices
- C# - LINQ, async/await, and .NET conventions
- Java - Modern Java 17+ features, streams, and design patterns
- JavaScript - ES6+ features and modern patterns
- Kotlin - Null safety, coroutines, and idiomatic patterns
- Python - Pythonic patterns and best practices
- Rust - Ownership, borrowing, and error handling
- TypeScript - Type system, generics, and React patterns
- Spring Boot (Java) - Dependency injection, REST APIs, JPA patterns
- Django (Python) - Models, views, QuerySet optimization
- FastAPI (Python) - Async patterns, Pydantic, dependency injection
- Flask (Python) - Blueprints, application factory, SQLAlchemy
- FastMCP (Python) - MCP server patterns and tool definitions
- Laravel (PHP) - Eloquent, routing, and Laravel conventions
- Symfony (PHP) - Symfony best practices and standards
- PHP - General PHP patterns and best practices
- Preserve Functionality - Never change what code does, only how it does it
- Enhance Clarity - Make code easier to understand and maintain
- Apply Standards - Follow framework-specific conventions
- Maintain Balance - Avoid over-simplification
- Focus Scope - Prioritize recently modified code
17 comprehensive guides covering:
- Universal principles (core.md)
- Language-specific patterns (8 files)
- Framework-specific conventions (8 files)
Access guides on-demand based on your current work context.
Uses Context7 MCP to provide up-to-date documentation:
- Query latest framework best practices
- Access current library documentation
- Ensure recommendations follow latest conventions
Two hooks for automated code simplification:
- File:
hooks/simplify-on-demand.json - Type: User-triggered
- Status: Ready to use
- Purpose: Click to get code review on-demand
- File:
hooks/simplify-on-save.json - Type: File-edited (automatic)
- Status:
⚠️ Disabled by default - Purpose: Auto-review on every file save
- Note: Enable explicitly if you want continuous feedback
- Open Kiro Powers panel
- Search for "Code Simplifier"
- Click "Install"
- The power and hooks will be available immediately
- Clone this repository
- In Kiro Powers UI, click "Add Custom Power"
- Select "Local Directory"
- Browse to this directory
- Click "Add"
-
Activate the power to read documentation:
Call action "activate" with powerName="code-simplifier" -
Read a specific guide for your language/framework:
Call action "readSteering" with powerName="code-simplifier", steeringFile="python-django.md" -
Query up-to-date docs via Context7:
Use resolve-library-id to find library Use query-docs to get current best practices
-
Install hooks (if not auto-installed with power):
# Linux/macOS cd hooks && ./install-hooks.sh # Windows cd hooks && install-hooks.bat
-
Open Agent Hooks panel in Kiro
-
Find "Simplify Code On-Demand"
-
Click trigger when you want a review
For testing: See hooks/TESTING.md for comprehensive
testing guide
- Open Agent Hooks panel
- Find "Simplify Code On Save (Disabled by Default)"
- Enable the hook
- Code will be reviewed automatically on every save
Supported file types: .js, .ts, .jsx, .tsx,
.py, .java, .kt, .rs, .c, .cpp, .cs, .php
- Modify your code
- Trigger the on-demand hook
- Review suggestions
- Apply improvements
- Identify the framework being used
- Load the appropriate steering file
- Query Context7 for current best practices
- Apply framework-specific patterns
- Enable the automatic hook
- Write code normally
- Get feedback on every save
- Disable when you want uninterrupted flow
This power requires a Context7 API key for accessing up-to-date documentation.
- Get your API key from https://context7.com
- Update
mcp.jsonwith your key:{ "mcpServers": { "context7": { "command": "npx", "args": [ "-y", "@upstash/context7-mcp", "--api-key", "YOUR_KEY_HERE" ] } } }
You can customize the hooks by editing the JSON files in the
hooks/ directory:
- Modify file patterns to watch different file types
- Adjust prompts to focus on specific aspects
- Change trigger conditions
See hooks/README.md for more details.
✅ Do simplify when:
- Code has unnecessary nesting or complexity
- Variable/function names are unclear
- Logic is duplicated
- Framework conventions aren't followed
- Code is harder to understand than necessary
❌ Don't simplify when:
- Code is already clear and maintainable
- Simplification would reduce readability
- Complexity is inherent to the problem
- Existing abstractions serve a clear purpose
Common patterns across all languages:
- Reduce nesting with early returns
- Use clear, descriptive names
- Eliminate code duplication
- Follow framework conventions
- Avoid nested ternary operators
- Prefer explicit over clever code
code-simplifier/
├── README.md # This file
├── POWER.md # Power documentation
├── LICENSE # License file
├── mcp.json # MCP server configuration
├── hooks/ # Agent hooks
│ ├── README.md # Hooks documentation
│ ├── simplify-on-demand.json # Manual trigger hook
│ └── simplify-on-save.json # Automatic hook (disabled)
└── steering/ # Language/framework guides
├── core.md # Universal principles
├── c.md # C language guide
├── csharp.md # C# language guide
├── java.md # Java language guide
├── java-spring.md # Spring Boot framework guide
├── js.md # JavaScript guide
├── kotlin.md # Kotlin language guide
├── python.md # Python language guide
├── python-django.md # Django framework guide
├── python-fastapi.md # FastAPI framework guide
├── python-fastmcp.md # FastMCP framework guide
├── python-flask.md # Flask framework guide
├── rust.md # Rust language guide
├── typescript.md # TypeScript guide
├── php.md # PHP language guide
├── php-laravel.md # Laravel framework guide
└── php-symfony.md # Symfony framework guide
Contributions are welcome! To add support for a new language or framework:
- Create a new steering file in
steering/ - Follow the existing structure and style
- Include:
- Naming conventions
- Language/framework-specific patterns
- Bad vs good code examples
- Simplification checklist
- Additional resources
- Update POWER.md to list the new guide
- Submit a pull request
- Verify API key is set correctly in mcp.json
- Check internet connection
- Restart Kiro to reconnect MCP server
- Ensure hooks are in the
hooks/directory - Check JSON syntax is valid
- Restart Kiro if needed
- Review the "Maintain Balance" principle in core.md
- Provide feedback: "Keep it more explicit"
- Request specific aspects to preserve
See LICENSE file for details.
- Kiro Documentation: https://kiro.dev/docs
- Context7: https://context7.com
- MCP Configuration: https://kiro.dev/docs/mcp/configuration/
- Agent Hooks Guide: https://kiro.dev/docs/hooks
1.0.0 - Initial release with support for 8 languages and 9 frameworks
Raishin
Keywords: code-simplification, refactoring, code-quality, maintainability, clean-code, code-review