Refactor comments that are code smells
Skill ceilidhboy/skills/skills/refactor-comments-that-are-code-smells
Agent skills for Laravel and PHP development. Installable via npx skills@latest add ceilidhboy/skills
npx -y skills add ceilidhboy/skills --skill refactor-comments-that-are-code-smellsAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Scans code for comments that explain what code does and refactors them using the action pattern or extracting to methods. Use after writing or editing any code.
SKILL.md
3.2 KB, as published. Nobody here has run it
Refactor Comments That Are Code Smells
Detection
A comment is a code smell when it:
- Explains what the next code block does (
// Get authenticator...) - Is a numbered list (
// 1. Do this, // 2. Do that) - Explains complex logic that should be extracted
Refactoring
Primary: Split into Actions
Follow the action-pattern skill. Split methods into single-responsibility actions:
// Before: one method with code-smell comments
public function execute(Client $client): array // Returns Contact
{
// 1. Search for existing contact
$connector = ...;
$response = $connector->send(new GetContactsRequest(...));
if ($contacts) return $contacts[0];
// 2. Create new contact
$response = $connector->send(new CreateContactRequest([...]));
return $response->json('Contacts')[0];
}
// After: separate actions
final readonly class SearchXeroContactByName
{
public function __construct(private GetAuthenticatedApiConnector $getConnector) {}
public function execute(Client $client): ?array // Returns Contact
{
$connector = $this->getConnector->execute();
$response = $connector->send(new GetContactsRequest(...));
return $response->json('Contacts')[0] ?? null;
}
}
final readonly class CreateXeroContact
{
public function __construct(private GetAuthenticatedApiConnector $getConnector) {}
public function execute(Client $client): array // Returns Contact
{
$connector = $this->getConnector->execute();
$response = $connector->send(new CreateContactRequest([...]));
return $response->json('Contacts')[0];
}
}
final readonly class FindOrCreateXeroContact
{
public function __construct(
private SearchXeroContactByName $search,
private CreateXeroContact $create,
) {}
public function execute(Client $client): array // Returns Contact
{
return $this->search->execute($client)
?? $this->create->execute($client);
}
}
Secondary: Extract to Methods
If not reusable, extract to private methods with semantic names:
// Before
$discount = $total > 100 ? 0.10 : ($total > 50 ? 0.05 : 0);
// After
private function calculateDiscount(int $total): float { ... }
Workflow
- Detect code-smell comments
- Choose approach (actions or methods)
- Propose refactoring to user — reference the action-pattern skill
- Get explicit approval before making changes
- Apply refactoring
- Verify tests pass
Action Pattern Reference
This skill works with the action-pattern skill. When refactoring to actions:
- Each action: one responsibility
- Use
final readonly class - Constructor injection for dependencies
- Public
execute()method - Actions compose via constructor injection
What NOT to Refactor
- PHPDoc blocks (documentation, not explanation)
- TODO comments (acceptable)
- Test explanations (test intent)
- Config comments (e.g.,
// seconds)
Gives 0 of the 12 instructions most refactoring skills give
Counted across 521 of the 525 authors here whose files we hold, read 2026-08-06
- run tests after each changein 59 of 521, across 56 files
- write tests before refactoringin 27 of 521, across 24 files
- preserve external behaviorin 26 of 521, across 22 files
- remove dead codein 25 of 521, across 24 files
- make small incremental changesin 20 of 521, across 17 files
- break the implementation into tiny commitsin 18 of 521, across 5 files
- ask the user about alternative optionsin 17 of 521, across 4 files
- create a GitHub issue with the planin 17 of 521, across 4 files
- explore the repository to verify assertionsin 17 of 521, across 4 files
- interview the user about the refactorin 16 of 521, across 3 files
- check the codebase for test coveragein 16 of 521, across 3 files
- refactor one thing at a timein 16 of 521, across 12 files
Said here and by no other author read
- detect comments explaining code blocks
- detect numbered list comments
- split methods into single-responsibility actions
- extract non-reusable logic to private methods
- reference the action-pattern skill when proposing refactoring
Grouped from the skills themselves: near-identical wordings counted once, and counted by distinct author, so one author publishing three of these counts once.