# Refactor Plan Agent Runbook

## Project Context To Prepare
- Project goal
- Current repository or workflow context
- Current context
- Goal
- Audience or stakeholder
- Constraints
- Available notes or data

## Input Template
Project:

Goal:

Current context:

Constraints:

Available files, notes, or data:

Expected output:
- refactor plan
- Safety net
- PR sequence
- Rollback steps

## Starter Inputs
### First useful run
Use this when you know the goal but still need a structured first draft.

Plan extraction of agent export formatting into smaller helpers without changing output.

Context:
- Current state:
- Constraints:
- Audience:
- Success criteria:

### Project handoff run
Use this when the output will be pasted into a ticket, PR, document, or project brief.

Goal: produce refactor plan for a real project.
Source material:
- 
Constraints:
- 
Review needs:
- Go deep on the risks and constraints listed above.
- Mark assumptions.
- Flag missing context.

### Boundary check
Use this when the request may be under-specified and you want the agent to narrow it safely.

Redesign the whole app architecture from a single component name.

Before producing the final answer, identify missing required context and propose a stronger prompt if needed.

## Setup Context Notes
- Bring current module boundaries, risky dependencies, unchanged behavior, and validation commands.
- Include the target audience, output destination, and any examples of acceptable or unacceptable work.
- Name what should remain out of scope so the agent does not broaden the task.

## Good Input Example
거대한 컴포넌트를 여러 모듈로 나누려는 상황

Goal: produce refactor plan for a real project.
Constraints: keep the result specific, structured, and ready for handoff.

## Weak Input Example
Help me with Refactor Plan Agent.

## Weak Input Diagnostics
### Help me with Refactor Plan Agent.
- Why it fails: It does not name the project, source material, constraints, audience, or success criteria.
- Stronger input: Plan extraction of agent export formatting into smaller helpers without changing output. Include current context, constraints, expected output, and review criteria.

### Make this better.
- Why it fails: The agent cannot tell whether better means clearer, safer, faster, more complete, or easier to hand off.
- Stronger input: Improve the output for 거대한 컴포넌트를 여러 모듈로 나누려는 상황. Optimize for refactor plan, keep assumptions explicit, and list the changes made.

## Expected Output Shape
- Safety net first: tests or snapshots to add and the commands that prove behavior is unchanged
- Steps, one PR each: what changes, files touched, verification commands and expected results, size, and rollback
- Risks: how each shows up and the check that catches it
- Other ideas kept to one line each under "Later"

## Output Checklist
- Every named constraint and caller is respected by each step, with how it is verified
- Each step has exact verification commands and a rollback
- Uses only the files, functions, and commands the user gave
- No behavior changes, features, or new dependencies unless the user asked for them
- A big-bang rewrite under time pressure is flagged, with safe first steps instead

## Failure Modes
- A step changes behavior without a check that would catch it
- Steps are too large to review in the stated time
- The plan relies on files or commands that were not given
- The plan schedules a big-bang rewrite instead of safe first steps

## Handoff Tips
- Paste relevant project files, notes, or constraints before asking for the final output.
- Ask for a first draft, then request a stricter revision using the checklist.
- Keep the generated output with the project ticket, PR, proposal, or team document.
