-
Notifications
You must be signed in to change notification settings - Fork 2.8k
feat: add code-simplify skill and /simplify slash command #10852
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
roomote
wants to merge
1
commit into
main
Choose a base branch
from
feature/add-simplify-skill-and-command
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+157
−25
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| import { SkillMetadata, SkillContent } from "./SkillsManager" | ||
|
|
||
| interface BuiltInSkillDefinition { | ||
| name: string | ||
| description: string | ||
| instructions: string | ||
| } | ||
|
|
||
| const BUILT_IN_SKILLS: Record<string, BuiltInSkillDefinition> = { | ||
| "code-simplify": { | ||
| name: "code-simplify", | ||
| description: | ||
| "Simplifies and refines code for clarity, consistency, and maintainability while preserving all functionality. Focuses on recently modified code unless instructed otherwise.", | ||
| instructions: `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. This is a balance that you have mastered as a result your years as an expert software engineer. | ||
|
|
||
| You will analyze recently modified code and apply refinements that: | ||
|
|
||
| 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 AGENTS.md and related documentation 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 | ||
| - IMPORTANT: Avoid nested ternary operators - prefer switch statements or if/else chains for multiple conditions | ||
| - Choose 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. | ||
|
|
||
| Your 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 | ||
|
|
||
| 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 elegance and maintainability while preserving its complete functionality.`, | ||
| }, | ||
| } | ||
|
|
||
| /** | ||
| * Get all built-in skills as SkillMetadata objects | ||
| */ | ||
| export function getBuiltInSkills(): SkillMetadata[] { | ||
| return Object.values(BUILT_IN_SKILLS).map((skill) => ({ | ||
| name: skill.name, | ||
| description: skill.description, | ||
| path: `<built-in:${skill.name}>`, | ||
| source: "built-in" as const, | ||
| })) | ||
| } | ||
|
|
||
| /** | ||
| * Get a specific built-in skill by name | ||
| */ | ||
| export function getBuiltInSkill(name: string): SkillContent | undefined { | ||
| const skill = BUILT_IN_SKILLS[name] | ||
| if (!skill) return undefined | ||
|
|
||
| return { | ||
| name: skill.name, | ||
| description: skill.description, | ||
| path: `<built-in:${skill.name}>`, | ||
| source: "built-in" as const, | ||
| instructions: skill.instructions, | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Get names of all built-in skills | ||
| */ | ||
| export function getBuiltInSkillNames(): string[] { | ||
| return Object.keys(BUILT_IN_SKILLS) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This import creates a circular dependency with
SkillsManager.ts, which imports from this file. While it works at runtime because these are type-only imports (erased during compilation), it's a code smell that could cause issues if runtime values are ever added. Import directly from the shared types module instead.Fix it with Roo Code or mention @roomote and request a fix.