refactor-command-to-commandlineresult
Migrates command classes to return raw results, isolating parsing logic.
Install
mkdir -p .claude/skills/refactor-command-to-commandlineresult && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/10419" && unzip -o skill.zip -d .claude/skills/refactor-command-to-commandlineresult && rm skill.zipInstalls to .claude/skills/refactor-command-to-commandlineresult
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Migrates a command class that still performs parsing or custom execution logic to return raw Git::CommandLineResult, moving parsing to facade/parser layers. Use during architectural redesign refactoring.Key capabilities
- →Extract parsing logic to facades
- →Migrate commands to Base pattern
- →Update YARD documentation
- →Update command tests
How it works
It migrates command classes to return raw CommandLineResult, moving parsing logic to dedicated facade or parser layers.
Inputs & outputs
When to use refactor-command-to-commandlineresult
- →Refactoring git commands
- →Moving parsing logic to facades
- →Modernizing architectural patterns
About this skill
Refactor Command to CommandLineResult
Migrate a command that still performs parsing or custom execution logic to the
Git::Commands::Base pattern, so command classes return raw
Git::CommandLineResult and parsing moves to facade/parser layers.
Contents
- How to use this skill
- Prerequisites
- Related skills
- Target end state
- Refactor steps
- What to remove from command classes
- What to update in tests
- YARD updates
- Migration process and internal compatibility
How to use this skill
Attach this file to your Copilot Chat context, then invoke it with the command class or source file to migrate. Examples:
Using the Refactor Command to CommandLineResult skill, migrate
Git::Commands::Stash::Pop to the Base pattern.
Refactor Command to CommandLineResult: lib/git/commands/branch/delete.rb
The invocation needs the command class name or file path of the command to refactor.
Prerequisites
Before starting, you MUST load the following skill(s) in their entirety:
- YARD Documentation — authoritative source for YARD formatting rules and writing standards;
Related skills
- Command Implementation — canonical class-shape checklist, phased rollout gates, and internal compatibility contracts
- Review Arguments DSL — verifying DSL entries match git CLI
- Command Test Conventions — unit/integration test conventions for command classes
- Facade Implementation — preserving
Git::Repository::*return-value contracts
Target end state
class SomeCommand < Git::Commands::Base
arguments do
...
end
# optional for non-zero successful exits
# rationale comment
# allow_exit_status 0..1
# @!method call(*, **)
#
# @overload call(**options)
#
# Execute the git ... command.
#
# @return [Git::CommandLineResult]
end
Refactor steps
- Move parsing/transforming logic out of command class into caller/facade/parser.
- Replace legacy
ARGSconstant + custominitializewitharguments do+ inheritance fromBase. - Remove custom
#callbody and add# @!method call(*, **)YARD directive. - If command requires non-default success exits, add
allow_exit_statuswith rationale comment. - Update callers to consume
CommandLineResultand parseresult.stdoutwhere needed.
What to remove from command classes
- parser invocations
- output transformation logic
literalentries for policy/output-control flags (e.g.literal '--no-edit',literal '--verbose',literal '--no-progress',literal '--no-color') — command classes are neutral, faithful representations of the git CLI; convert toflag_option/value_optionso the facade can pass the policy value. See "Command-layer neutrality" in CONTRIBUTING.md.- manual
raise_on_failure/ manual exit-code checks (unless temporarily needed in an unmigrated class) - duplicated bind/execute logic
What to update in tests
- unit specs should assert CLI args and
CommandLineResultbehavior - remove parsed-object assertions from command unit specs
- move parsing expectations to parser/facade tests
- include
raise_on_failure: falsein mocked command expectations
YARD updates
- update
@returntoGit::CommandLineResult - keep command-specific
@overloaddocs nested under# @!method call(*, **)directive - ensure
@raisewording reflects allowed range behavior - tag short descriptions must not end with punctuation (no trailing period, comma, or colon)
- multi-paragraph tag descriptions must have a blank comment line (
#) between the short description and each continuation paragraph
Migration process and internal compatibility
See Command Implementation for the canonical phased rollout checklist and internal compatibility contract. In summary:
- always work on a feature branch — never commit or push directly to
main; create a branch before starting (git checkout -b <feature-branch-name>) and open a pull request when the slice is ready - perform refactor in phased slices (pilot/family)
- keep each slice independently revertible
- do not mix unrelated behavior changes with refactor-only changes
- pass slice gates:
bundle exec rspec,bundle exec rake test,bundle exec rubocop,bundle exec rake yard
When not to use it
- →Mixing unrelated behavior changes
Prerequisites
Limitations
- →Requires phased rollout
- →Requires manual test updates
How it compares
This enforces a clean architectural separation of concerns compared to legacy commands that handle both execution and parsing.
Compared to similar skills
refactor-command-to-commandlineresult side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| refactor-command-to-commandlineresult (this skill) | 0 | 4mo | No flags | Advanced |
| ast-grep-find | 3 | 7mo | Review | Intermediate |
| clean | 4 | 3mo | Review | Intermediate |
| code-transfer | 1 | 9mo | Review | Beginner |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by ruby-git
View all by ruby-git →You might also like
ast-grep-find
parcadei
AST-based code search and refactoring via ast-grep MCP
clean
catlog22
Intelligent code cleanup with mainline detection, stale artifact discovery, and safe execution. Supports targeted cleanup and confirmation.
code-transfer
mhattingpete
Transfer code between files with line-based precision. Use when users request copying code from one location to another, moving functions or classes between files, extracting code blocks, or inserting code at specific line numbers.
framework-migration-code-migrate
sickn33
You are a code migration expert specializing in transitioning codebases between frameworks, languages, versions, and platforms. Generate comprehensive migration plans, automated migration scripts, and
tdd-migrate
parcadei
TDD workflow for migrations - orchestrate agents, zero main context growth
windsurf-multi-file-editing
jeremylongshore
Manage multi-file edits with Cascade coordination. Activate when users mention "multi-file edit", "edit multiple files", "cross-file changes", "refactor across files", or "batch modifications". Handles coordinated multi-file operations. Use when working with windsurf multi file editing functionality. Trigger with phrases like "windsurf multi file editing", "windsurf editing", "windsurf".