Simplify

From RedWoodOG/Hermes-Desktop · View interactive version

Simplify is an AI agent skill from the GitHub repository RedWoodOG/Hermes-Desktop. Review changed code for reuse, quality, and efficiency, then fix any issues found.

How to use this skill

Skill file

Simplify: Code Simplification and Quality Review

You are a senior engineer performing a code simplification review. Your goal is to find and fix opportunities to reduce complexity, improve reuse, and increase efficiency in recently changed code.

Workflow

Step 1: Identify Recent Changes

Run git diff HEAD~1 (or git diff --cached if there are staged changes) to see what has changed. If the user specifies a range or branch, use that instead.

git diff --name-only HEAD~1
git diff HEAD~1

If no git changes exist, ask the user which files or directories to review.

Step 2: Analyze Each Changed File

For every changed file, read the full file (not just the diff) to understand context. Look for:

  1. Duplicated logic - Code that repeats patterns already present elsewhere in the codebase. Use grep to search for similar function names, string literals, or logic patterns.
  2. Over-engineering - Abstractions that add complexity without clear benefit. Classes with one implementation, factories that produce one type, wrappers that just delegate.
  3. Dead code - Unused imports, unreachable branches, commented-out blocks, variables assigned but never read.
  4. Long functions - Functions exceeding ~40 lines that can be decomposed into named sub-operations.
  5. Deep nesting - More than 3 levels of indentation. Use early returns, guard clauses, or extraction to flatten.
  6. Magic values - Unexplained numeric or string literals. Extract to named constants.
  7. Redundant conditions - Boolean expressions that can be simplified (if x == true to if x, double negations, tautologies).
  8. Inefficient patterns - O(n^2) where O(n) is possible, repeated computation that could be cached, string concatenation in loops.
  9. Missing reuse - Utility functions or shared components in the project that the new code could leverage instead of reimplementing.

Step 3: Search for Reuse Opportunities

For each significant block of new logic, search the codebase for existing implementations:

grep -r "functionNameOrPattern" --include="*.{ts,js,py,cs,java}" .

Check for:

Step 4: Apply Fixes

For each issue found, use edit_file to make the improvement directly. Prioritize changes by impact:

  1. High - Duplicated code that should use an existing function, bugs from complexity
  2. Medium - Long functions that should be split, dead code removal
  3. Low - Style improvements, minor naming clarifications

Step 5: Verify

After all edits, run any available linter or test command to ensure nothing is broken:

# Try common patterns
npm test 2>/dev/null || dotnet test 2>/dev/null || python -m pytest 2>/dev/null || echo "No test runner detected"

Step 6: Report

Provide a summary listing:

Principles

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.