refine
Skill2 starsChanged 9 months agoMITView on GitHub
Iterative refinement loop for modules/components. Research best practices, council-deliberate a spec, collect issues, implement in worktree, review — one target at a time, approval-gated. Auto mode for fully autonomous operation.
- Commits and pushes
23 other projects use a version of this.
Adopted by
Most recently taken up by
- ghostdogpr/skillstheir own version, first seen Oct 5, 2026
- michielvandermeer/skillstheir own version, first seen Oct 4, 2026
- ryanportfolio/Harness-Firmwaretheir own version, first seen Oct 3, 2026
- ryanportfolio/Corewise.Academytheir own version, first seen Oct 3, 2026
- GavinGreenwood/agentic-workflow-templatetheir own version, first seen Oct 2, 2026
- ong6/skillstheir own version, first seen Oct 2, 2026
Used with
Projects with it also use addskill, advocate and 10 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
ryanportfolioSkilladdskill
Create, import, update, or install repository or personal skills; includes runtime ownership, resources, and discovery validation.
Also in 3 projects that use this
ryanportfolioSkilladvocate
Use only when the user explicitly invokes $advocate to challenge a change just made before it lands. Do not trigger from natural-language requests.
Also in 3 projects that use this
- +10 more from ryanportfolio
Other versions23 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 23
- skyllwt/AutoSci★ 1.7ksame name
- automagik-dev/genie★ 345same name
- rsi-gear/gear★ 133same name
- Lambenthan/empiricalwiki★ 91same name
- unclejobs-ai/second-claude-code★ 40same name
- ghostdogpr/skills★ 17same name
- michielvandermeer/skills★ 9same name
- GavinGreenwood/agentic-workflow-template★ 4same name
- Darcos-Loft/fluid★ 3same name
- mia-cx/skills★ 3same name
13 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository18 other files it gives its agents.
- affirmationSkill
- auditSkill
- councilSkill
- doSkill
- gitSkill
- infoSkill
- kill-playgroundSkill
- memorySkill
- mergeSkill
- opsSkill
- qSkill
- runSkill
- scopeSkill
- sim-sourceSkill
- stateSkill
- thinkSkill
- ui-brainSkill
- worktree-managerSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
41 rules. 0 are common, 21 are distinctive, and 20 are very specific to this project.
0
Common
Most of the 18 edited versions we read keep these.
21
Distinctive
This author's own choices. Worth a look.
20
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 66
All output that would normally go to the user goes to REFINE_STATUS.md in the repo root (NOT the worktree).
- Very specific: line 150
Create worktree manually (same as /do Step 2): git worktree add -b "refine/auto-{timestamp}" ".worktrees/refine-auto-{timestamp}"
- Very specific: line 152
Create REFINE_STATUS.md at repo root with initial structure.
- Very specific: line 153
Start state session: mcp__state__session_start(skill: "refine", repo: {cwd}, scope: "auto", payload: {initial state}).
- Distinctive: line 160
If the user provided context at invocation, include it as additional research input
- Very specific: line 167
If an existing *.spec.md exists, update it.
- Distinctive: line 186
If changes made → commit with conventional message
- Distinctive: line 187
If no changes → log "no changes needed" to status file
- Distinctive: line 188
If error → log error to status file, mark target as "failed", continue to next
- Distinctive: line 190
No user confirmation. No preview server.
- Distinctive: line 196
If the target is a UI component and visual tooling is available:
- Very specific: line 198
Web reference: Start web playground (vite), use Playwright to screenshot the component section at mobile viewport (390×844).
- Distinctive: line 199
Native comparison: If Maestro + Java 17+ available AND a simulator is booted, use Maestro to navigate to the component section and …
- Distinctive: line 200
Compare: Read both screenshots. Note visual discrepancies.
- Distinctive: line 201
Auto-fix: If discrepancies are clearly token/styling issues (wrong spacing, color, radius), fix them in the worktree and re-commit.
- Distinctive: line 202
Defer: If discrepancies require design decisions or are ambiguous, log to status file under "Questions for User".
- Distinctive: line 206
No web playground section exists for the target
- Distinctive: line 212
Update status file: mark target as "done", add commit SHA and change summary
- Very specific: line 219
Update REFINE_STATUS.md with final summary
- Distinctive: line 227
After INIT, analyze target directories for overlap.
- Distinctive: line 238
Fail forward: If a target fails, log it and continue.
- Distinctive: line 264
If input is a glob → expand with Glob tool, group by parent directory (one target = one directory).
- Distinctive: line 265
If input is a file path → target is that file's parent directory.
- Very specific: line 266
If input is a name → search for /{name}/ or /{name}.tsx and resolve to directory.
- Distinctive: line 295
If result is not null → interrupted session found:
- Very specific: line 297
If last checkpoint has git_ref, verify it: git cat-file -t {git_ref} (exists = phase completed)
- Distinctive: line 302
If result is null → fresh start.
- Very specific: line 315
Call mcp__state__session_complete(session_id) after all targets are done.
- Very specific: line 319
Call mcp__state__session_abandon(session_id) when user chooses abort.
- Very specific: line 339
Read the target's existing files — source, spec (*.spec.md, *.ai.md), tests, stories.
- Very specific: line 404
Checkpoint: Call mcp__state__session_checkpoint with phase: "SPEC" and state including researchBrief.
- Very specific: line 537
After /do merges successfully:
- Very specific: line 546
Checkpoint with git_ref: Call mcp__state__session_checkpoint with phase: "SHIP", updated state (target added to completedTargets, …
- Very specific: line 553
If more targets remain → advance currentIndex, reset currentPhase to RESEARCH, continue loop.
- Distinctive: line 555
If all targets done:
- Very specific: line 582
Read ~/.claude/skills/memory/MEMORY_OPS.md for tool call templates.
- Distinctive: line 595
One target at a time: Never parallelize across targets — the user reviews each.
- Very specific: line 596
Approval gates are mandatory: Every phase transition requires explicit user input via AskUserQuestion.
- Distinctive: line 597
Research is real: Use web search, not hallucinated library APIs.
- Very specific: line 598
Council for specs: Always use /council --subroutine for spec drafts.
- Very specific: line 599
Implementation via
/do: Always in a worktree. Never edit the main tree directly.
“Common” is measured: kept by at least 6 in 10 of the 18 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Refine
Iterative, approval-gated refinement loop for any module, component, or group thereof. Researches best practices, councils a spec, collects known issues, implements in a worktree, reviews with the user — then moves to the next target.
/refine <glob|file|list> — refine targets one by one (auto-resumes interrupted sessions)
/refine <targets> --auto [context] — fully autonomous: no approval gates, status tracked in .md fileFlow (per target)
/refine <targets>
|
For each target:
|
RESEARCH — web search + library survey for best practices
| User: approve findings / add notes
|
SPEC — /council spec draft → user iteration loop
| User: approve / refine (loop)
|
ISSUES — user lists implementation problems
| User: done listing / skip
|
IMPLEMENT — /do in worktree (spec + code updates)
| User: merge / request changes / discard
|
SHIP — commit, push, confirm → next target--auto — Autonomous Mode
Fully autonomous refinement. No AskUserQuestion gates. All decisions, status, issues, and questions are written to a status file instead of waiting for user input.
When to use
- User explicitly wants unattended operation ("do this autonomously", "handle this overnight")
- Multiple targets that don't need per-target approval
- User wants to review the batch outcome, not each step
Invocation
/refine <targets> --auto [additional context or instructions]The second argument (optional) is free-form context: constraints, source of truth pointers, known issues, etc. This replaces the ISSUES phase — the user front-loads what they know.
Status File: REFINE_STATUS.md
All output that would normally go to the user goes to REFINE_STATUS.md in the repo root (NOT the worktree). This file is the user's async review surface.
Create at startup. Update after every phase. Structure:
# /refine --auto — Status
**Branch:** `{worktree branch}`
**Started:** {ISO date}
**Updated:** {ISO date}
**Status:** {IN PROGRESS | COMPLETE | FAILED}
**Targets:** {N total}, {N complete}, {N remaining}
---
## Progress
| # | Target | Status | Notes |
|---|--------|--------|-------|
| 1 | Button | done | aligned native tokens with web |
| 2 | Badge | done | pill radius, size tokens |
| 3 | Dialog | in progress | ... |
| 4 | Tabs | pending | |
## Current: {targetName} — {phase}
{Brief description of what's happening right now}
## Decisions Made
- {target}: {decision} — {rationale}
- ...
## Issues Found
- {target}: {issue description} — {status: fixed | deferred | needs-user-input}
- ...
## Questions for User
- {question} (context: {why this matters})
- ...
## Completed Targets
### {targetName}
**Changes:** {summary}
**Commit:** `{sha}`
**Files:** {list}Auto Mode Flow
/refine <targets> --auto [context]
|
INIT — resolve targets, create worktree, create REFINE_STATUS.md
|
For each target (parallelizable when file-disjoint):
|
RESEARCH — same as standard, but findings go to status file, not AskUserQuestion
| Decision: auto-continue (no gate)
|
SPEC — /council --subroutine, auto-approve
| Decision: council output accepted (no refinement loop)
|
ISSUES — skip (user context from invocation replaces this)
|
IMPLEMENT — /do --yolo (auto-merge on success)
| On failure: log to status file, continue to next target
|
VERIFY — visual comparison if applicable (Playwright web, Maestro/simctl native)
| Findings logged to status file; auto-fix what's obvious, defer rest
|
SHIP — commit, update status file
|
REPORT — final status file update, summaryPhase Details (auto mode overrides)
INIT
- Resolve targets (same as standard).
- Create worktree manually (same as
/doStep 2):git worktree add -b "refine/auto-{timestamp}" ".worktrees/refine-auto-{timestamp}" - Symlink
node_modules. - Create
REFINE_STATUS.mdat repo root with initial structure. - Start state session:
mcp__state__session_start(skill: "refine", repo: {cwd}, scope: "auto", payload: {initial state}).
RESEARCH (auto)
Same research agent as standard mode, but:
- Findings written to status file under the current target section
- No
AskUserQuestion— auto-continue - If the user provided context at invocation, include it as additional research input
SPEC (auto)
- Invoke
/council --subroutine(same as standard) - Auto-approve the council output — no refinement loop
- Spec content written to status file and stored in state
- If an existing
*.spec.mdexists, update it; if not, create one
ISSUES (auto)
- Skipped entirely. The user's invocation context replaces this phase.
- Any issues discovered during RESEARCH or IMPLEMENT are logged to the status file under "Issues Found"
IMPLEMENT (auto)
Spawn implementation agent directly (not via /do — avoid the nested approval gate):
Agent(
prompt: {worker prompt with spec + research + user context},
mode: "bypassPermissions"
)Worker runs in the worktree. On completion:
- If changes made → commit with conventional message
- If no changes → log "no changes needed" to status file
- If error → log error to status file, mark target as "failed", continue to next
No user confirmation. No preview server.
VERIFY (auto)
Optional phase — only runs when visual comparison is possible.
If the target is a UI component and visual tooling is available:
- Web reference: Start web playground (
vite), use Playwright to screenshot the component section at mobile viewport (390×844). - Native comparison: If Maestro + Java 17+ available AND a simulator is booted, use Maestro to navigate to the component section and screenshot. Otherwise, skip native screenshots.
- Compare: Read both screenshots. Note visual discrepancies.
- Auto-fix: If discrepancies are clearly token/styling issues (wrong spacing, color, radius), fix them in the worktree and re-commit.
- Defer: If discrepancies require design decisions or are ambiguous, log to status file under "Questions for User".
Skip conditions:
- Target is not a UI component (e.g., utility, hook, config)
- No web playground section exists for the target
- Playwright not available
SHIP (auto)
- Push the worktree branch (but do NOT merge to main — user merges after review)
- Update status file: mark target as "done", add commit SHA and change summary
- Checkpoint state
- Continue to next target
REPORT (auto)
After all targets:
- Update
REFINE_STATUS.mdwith final summary - Complete state session
- Print one-line notification:
"/refine --auto complete — {N} targets. Review REFINE_STATUS.md"
Parallelization in Auto Mode
Unlike standard /refine (strictly serial), auto mode MAY parallelize targets when they are file-disjoint:
- After INIT, analyze target directories for overlap.
- Group file-disjoint targets into batches.
- Within each batch, spawn parallel agents (max 5, same as
/run --workers). - Between batches, serialize (wait for all in batch N before starting batch N+1).
- Status file updates must be serialized (one writer at a time — agent results collected by the orchestrator, not written by workers directly).
Auto Mode Rules
- No
AskUserQuestion. Ever. Everything goes to the status file. - No merge to main. Auto mode pushes a branch. User merges after review.
- Status file is the contract. User reviews
REFINE_STATUS.mdfor decisions, issues, questions. - Fail forward. If a target fails, log it and continue. Don't abort the batch.
- Conventional commits. Each target gets its own commit (or commits) with conventional messages.
- Same worktree for all targets. One worktree, sequential commits. Parallelized agents all write to the same worktree (serialized merge back).
- User context replaces ISSUES. Whatever the user passed at invocation is the issue list.
- Council is non-negotiable. Even in auto mode, specs go through
/council --subroutine. No shortcutting the multi-persona deliberation.
Example
/refine "ButtonGroup, Badge, Card, Dialog, Sheet, Toast" --auto on NATIVE only: Card should default to raised. Checkbox small icon gets cutoff. Use web playground as source of truth for visual comparison.→ Resolves 6 targets. Creates worktree. For each: researches, councils a spec, implements, verifies visually, commits. Status tracked in REFINE_STATUS.md. User reviews the file and the branch when ready.
Input
Accepts any of:
- Glob:
"src/components/Button/**"— expands to matching dirs/files - File path:
"src/components/Menu/Menu.tsx"— single target - Comma-separated list:
"Button, Menu, Dialog"— resolved via codebase search - Bare names: searched as component/module names in the repo
Target Resolution
- If input is a glob → expand with Glob tool, group by parent directory (one target = one directory).
- If input is a file path → target is that file's parent directory.
- If input is a name → search for
**/{name}/**or**/{name}.tsxand resolve to directory. - Deduplicate. Sort alphabetically.
- Print the target list and ask user to confirm or reorder before starting.
State Tracking (session-persisted)
State is persisted via the state MCP server. Sessions survive conversation disconnects.
State shape (JSON payload)
{
"targets": ["Button", "Menu", "Dialog"],
"currentIndex": 0,
"currentPhase": "RESEARCH",
"completedTargets": [],
"researchBrief": null,
"specContent": null,
"issueList": null
}Session lifecycle
On startup (before target resolution):
- Call
mcp__state__session_resume(skill: "refine", repo: {cwd}). - If result is not null → interrupted session found:
- Parse last checkpoint's
state_jsonto recover state - If last checkpoint has
git_ref, verify it:git cat-file -t {git_ref}(exists = phase completed) - Show:
"Found interrupted /refine session ({currentIndex+1}/{total}, phase: {phase}). Resume or discard?" AskUserQuestionwith options: resume / discard- On discard →
mcp__state__session_abandon(session_id), then proceed fresh - On resume → skip to the recovered phase/target
- Parse last checkpoint's
- If result is null → fresh start. After target resolution + user confirmation:
mcp__state__session_start(skill: "refine", repo: {cwd}, payload: {initial state JSON})
At each phase transition:
Call mcp__state__session_checkpoint with:
session_id: the active session IDphase: current phase name (e.g., "RESEARCH", "SPEC", "ISSUES", "IMPLEMENT", "SHIP")state_json: full state snapshot (JSON stringified)git_ref: commit SHA if a commit was made (SHIP phase), omit otherwise
On completion:
Call mcp__state__session_complete(session_id) after all targets are done.
On abort:
Call mcp__state__session_abandon(session_id) when user chooses abort.
Phase header
At the start of each phase, print:
[{currentIndex + 1}/{totalTargets}] {targetName} — {currentPhase}Phase 1: RESEARCH
Goal: Gather conventions, standards, and best practices for this type of component/module.
Checkpoint: At the start of this phase, call mcp__state__session_checkpoint with phase: "RESEARCH" and the current state snapshot.
- Identify what kind of component/module the target is (e.g., Dialog, Menu, Tabs, Form).
- Read the target's existing files — source, spec (
*.spec.md,*.ai.md), tests, stories. - Launch a research agent (
subagent_type: "general-purpose") with web search:
Research best practices, conventions, and API design for a {component_type} component/module.
Look at what is established in top libraries:
- shadcn/ui
- Radix UI
- React Aria (Adobe)
- MUI (Material UI)
- Headless UI
- Ark UI
- Melt UI
For each library, note:
1. Props / API surface
2. Accessibility patterns (ARIA roles, keyboard nav)
3. Composition model (compound components, slots, render props)
4. State management approach
5. Notable design decisions or conventions
Synthesize into a unified "best practices" summary covering:
- Must-have features
- Accessibility requirements (WCAG)
- Keyboard interaction model
- Common pitfalls to avoid
- API design consensus across libraries
Be thorough but concise. Bullet points, not prose.- Present findings to the user:
## Research: {targetName}
### Component Type
{identified type}
### Best Practices Summary
{synthesized findings}
### Current State
{summary of what exists in the target today}
### Gaps
{what the current implementation is missing vs. best practices}AskUserQuestion:
Review the research above. Reply:
- **continue** — proceed to spec drafting
- **add: {notes}** — append your own findings, then continue
- **skip-to: spec|issues|implement** — jump aheadOn add: → append notes to the research brief, confirm, then proceed.
Phase 2: SPEC
Checkpoint: Call mcp__state__session_checkpoint with phase: "SPEC" and state including researchBrief.
Goal: Draft or update the target's spec via council deliberation, iterated with the user.
- Invoke
/councilas a subroutine:
Skill: council
Args: "Draft a component spec for {targetName} ({component_type}).
Context from research:
{research_brief}
Current implementation:
{summary of existing code, props, behavior}
Existing spec (if any):
{contents of *.spec.md or *.ai.md, or 'None'}
Produce a complete spec covering:
- Purpose & when to use
- Anatomy (parts/slots)
- Props / API surface
- Variants & states
- Accessibility (ARIA, keyboard interaction model)
- Responsive behavior
- Do's and Don'ts
Format as a spec.md document." --subroutine- Present the council's spec draft:
## Proposed Spec: {targetName}
{council output — the full spec draft}AskUserQuestion:
Review the spec draft above. Reply:
- **approve** — lock this spec, move to issues
- **refine: {feedback}** — revise and show again
- **skip** — keep existing spec, move to issuesRefinement Loop
On refine: {feedback}:
- Re-invoke
/councilwith the feedback as an additional constraint. - Re-present the updated spec.
- Ask again.
Loop until approve or skip. No limit on rounds.
On skip: proceed with the existing spec (or no spec if none exists).
Phase 3: ISSUES
Checkpoint: Call mcp__state__session_checkpoint with phase: "ISSUES" and state including specContent.
Goal: Collect the user's known issues with the current implementation.
AskUserQuestion:
List any issues with the current {targetName} implementation.
Examples: broken behavior, missing features, wrong patterns, style violations, a11y gaps.
Reply:
- **{your list}** — I'll incorporate these into the implementation
- **skip** — no known issues, proceed to implement- On response: store the issue list. Confirm:
Got it — {N} issues noted. Moving to implementation.On skip: proceed with spec + research only.
Phase 4: IMPLEMENT
Checkpoint: Call mcp__state__session_checkpoint with phase: "IMPLEMENT" and state including issueList.
Goal: Apply all gathered context (research + spec + issues) in an isolated worktree.
Invoke /do with a comprehensive instruction set:
Skill: do
Args: "Refine {targetName} based on the following:
## Approved Spec
{spec content — from Phase 2, or existing spec if skipped}
## Research Summary
{research brief from Phase 1}
## Issues to Fix
{issue list from Phase 3, or 'None'}
## Instructions
1. Update the spec file ({spec_path}) with the approved spec content.
2. Update the component/module implementation to match the spec.
3. Fix all listed issues.
4. Ensure accessibility requirements are met.
5. Run any existing tests; fix if broken.
6. Do NOT modify files outside this target's directory unless strictly necessary."/do handles: worktree creation → agent execution → diff preview → user confirmation (merge/open/discard).
If discarded
AskUserQuestion:
Implementation discarded. What next?
- **retry: {feedback}** — re-run /do with adjustments
- **skip** — move to next target without changes
- **abort** — stop the entire /refine sessionOn retry: → re-invoke /do with the additional feedback appended.
Phase 5: SHIP
After /do merges successfully:
- Push the current branch:
git push- Get the commit SHA:
git rev-parse HEAD - Checkpoint with git_ref: Call
mcp__state__session_checkpointwithphase: "SHIP", updated state (target added tocompletedTargets,currentIndexadvanced), andgit_ref: {commit SHA}. - Confirm:
{targetName} complete. [{currentIndex + 1}/{totalTargets}] done.- If more targets remain → advance
currentIndex, resetcurrentPhaseto RESEARCH, continue loop. - If all targets done:
- Call
mcp__state__session_complete(session_id). - Print:
- Call
All {totalTargets} targets refined:
{bulleted list of completedTargets}Skip Gates
At any AskUserQuestion, the user can jump phases:
| Command | Effect |
skip | Skip current phase, proceed to next |
skip-to: {phase} | Jump to named phase |
abort | Stop the entire session → session_abandon |
next | Skip remaining phases for this target, move to next target |
These allow fast-tracking simple targets while keeping the full loop for complex ones.
Memory Integration
Read ~/.claude/skills/memory/MEMORY_OPS.md for tool call templates.
| Point | Action |
| RESEARCH start | recall-prior-art with component type keywords |
| SPEC approved | store-decision with key spec decisions + rationale |
| User refines spec | store-feedback with refinement reasoning |
| SHIP complete | store-decision with summary of what changed and why |
Rules
- One target at a time. Never parallelize across targets — the user reviews each. (Auto mode exception: file-disjoint targets may parallelize.)
- Approval gates are mandatory. Every phase transition requires explicit user input via
AskUserQuestion. (Auto mode exception: all gates replaced by status file logging.) - Research is real. Use web search, not hallucinated library APIs. Cite specifics.
- Council for specs. Always use
/council --subroutinefor spec drafts. No shortcutting. - Implementation via
/do. Always in a worktree. Never edit the main tree directly. (Auto mode: direct agent in worktree with--yolosemantics.) - Composable. This skill calls
/counciland/do— it does not reimplement them. - Resumable. Sessions are persisted via
stateMCP.session_resumeat startup auto-detects interrupted work. - No edits before IMPLEMENT. Phases 1-3 are strictly read-only + research. First write happens inside
/do. - Push after merge. SHIP always pushes so progress is saved before moving on.
- Auto mode: never merge to main. Push the branch. User merges after reviewing
REFINE_STATUS.md.
Example
/refine "Menu, Dialog, Tooltip, Popover"Resolves to 4 target directories. For each one:
- Researches best practices across top libraries
- Councils a spec draft, iterates with user
- Collects known issues
- Implements in worktree via
/do - Pushes, moves to next
/refine "src/components/**"Expands glob. If a previous session was interrupted, auto-detects and offers to resume from where it left off.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

