# Refactor Code

> Improve code structure and readability

- Skill: `cowork-os/refactor-code` (Agent Skill)
- Install (CLI): `npx skillmds@latest add cowork-os/refactor-code`
- Raw SKILL.md: https://api.skillmd.com/api/skills/cowork-os/refactor-code/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: cowork-os (https://skillmd.com/u/cowork-os)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/cowork-os/refactor-code

---


# Refactor Code

## Purpose

Improve code structure and readability

## Routing

- Use when: Use when user asks to improve maintainability, readability, modularity, or error handling in code.
- Do not use when: Don't use for behavior-only fixes where refactor risk is unnecessary.
- Outputs: Refactor changes, rationale, and minimal review checklist for behavior-sensitive sections.
- Success criteria: Preserves behavior while improving structure and readability.

## Trigger Examples

### Positive

- Use the refactor-code skill for this request.
- Help me with refactor code.
- Use when user asks to improve maintainability, readability, modularity, or error handling in code.
- Refactor Code: provide an actionable result.

### Negative

- Don't use for behavior-only fixes where refactor risk is unnecessary.
- Do not use refactor-code for unrelated requests.
- This request is outside refactor code scope.
- This is conceptual discussion only; no tool workflow is needed.

## Parameters

| Name | Type | Required | Description |
|---|---|---|---|
| path | string | Yes | Path to the file to refactor |
| focus | select | Yes | What to focus on |

## Runtime Prompt

- Current runtime prompt length: 235 characters.
- Runtime prompt is defined directly in `../refactor-code.json`. 

