Agent skill

refactoring

Guide for safe and effective code refactoring. Focuses on improving code structure without changing external behavior. Covers patterns like extraction, inlining, and naming improvements.

Stars 1
Forks 0

Install this agent skill to your Project

npx add-skill https://github.com/s-hiraoku/synapse-a2a/tree/main/.agents/skills/refactoring

SKILL.md

Refactoring Guide Skill

Refactoring is the process of restructuring existing computer code—changing the factoring—without changing its external behavior.

Core Refactoring Patterns

1. Composing Methods

  • Extract Method: If a method is too long or complex, turn a fragment of it into its own method.
  • Inline Method: If a method body is as clear as its name, move the body into the callers and delete the method.

2. Moving Features Between Objects

  • Move Method/Field: Relocate logic to the class where it most naturally belongs to reduce coupling.

3. Simplifying Expressions

  • Decompose Conditional: Extract complex conditional logic into clearly named methods.
  • Consolidate Conditional Expression: Merge multiple conditional checks that lead to the same result.

4. Clean Code & Naming

  • Rename: Use clear, intention-revealing names for variables, methods, and classes.
  • Replace Magic Number with Symbolic Constant: Use named constants instead of literal numbers.

Safe Refactoring Workflow

  1. Verify Tests: Ensure you have a solid test suite that passes before starting.
  2. Small Steps: Make one tiny change at a time.
  3. Run Tests: Execute the test suite after every small change to catch regressions immediately.
  4. Commit Often: Commit your changes once a small refactoring step is complete and verified.

When to Refactor

  • Rule of Three: Refactor when you find yourself doing something for the third time.
  • Code Smells: Refactor when you encounter long methods, large classes, or duplicated code.
  • Adding Features: Refactor before adding new functionality to make the implementation easier.

Expand your agent's capabilities with these related and highly-rated skills.

s-hiraoku/synapse-a2a

task-planner

Guide for decomposing large tasks into a structured plan with dependency chains, managing priorities, and distributing work across agents. Outputs plan cards or delegation messages as the team contract; TodoList for personal micro-steps.

1 0
Explore
s-hiraoku/synapse-a2a

react-performance

Comprehensive React and Next.js performance optimization guide. Covers waterfall elimination, bundle size reduction, server-side optimization, re-render prevention, and rendering performance. Use when building, reviewing, or optimizing React/Next.js applications for speed.

1 0
Explore
s-hiraoku/synapse-a2a

release

Update version in pyproject.toml, plugin.json, and add changelog entry. This skill should be used when the user wants to bump the version number and update CHANGELOG.md. Triggered by /release or /version commands.

1 0
Explore
s-hiraoku/synapse-a2a

api-design

Guide API design for REST, GraphQL, gRPC, and CLI interfaces. Use this skill when designing new APIs, reviewing existing API contracts, or establishing API conventions for a project. Produces consistent, well-documented API specifications.

1 0
Explore
s-hiraoku/synapse-a2a

pr-guardian

Continuously monitor a GitHub PR for merge conflicts, CI failures, and CodeRabbit review comments, then automatically fix any issues found. Polls every 5 minutes and loops until every check is green. Use this skill whenever a PR has just been created or code has been pushed to a PR branch — it should be the default follow-up action after any PR creation or push. Also trigger on: "watch this PR", "guard this PR", "monitor CI", "keep fixing until green", "PRを監視して", "CIが通るまで 直して", /pr-guardian. When a PostToolUse hook reports that a push or PR creation just happened, proactively invoke this skill to start monitoring without waiting for the user to ask.

1 0
Explore
s-hiraoku/synapse-a2a

post-impl2

Workflow: Test workflow with non-existent agent target. . Triggered by /post-impl2 command.

1 0
Explore

Didn't find tool you were looking for?

Be as detailed as possible for better results