Setup development environment from GitHub issue. Invoke when user says "init work on issue
Transform a GitHub issue into a fully-prepared development environment with:
Before beginning, load critical project context:
Read the project's CLAUDE.md to understand:
Get a high-level view of the repository structure to identify affected areas.
Before proceeding with setup, check if work already initialized:
Detect existing scratchpad:
# Look for SCRATCHPAD_{issue_number}.md
ls SCRATCHPAD_*.md 2>/dev/null
If scratchpad exists:
β Scratchpad already exists for this issue.
Delegating to do-work skill...
Then invoke:
Skill: do-work
args: "{issue_number}"
STOP here - don't proceed with setup.
If no scratchpad:
Input: Issue reference in format owner/repo#number or just #number (uses current repo)
Examples:
owner/repository#42#42 (assumes current repository)Execute these operations in parallel for faster setup:
Repository Context:
CLAUDE.md for conventionsIssue Details:
Generate branch name (after issue fetched):
{issue-number}-{slugified-title}42-implement-fact-batchingBuild issue context map:
Goal: Understand the issue deeply before writing any code.
Analysis Steps:
Requirements Review:
Codebase Investigation (Delegate to Scratchpad-Planner Agent):
For thorough codebase analysis, use the scratchpad-planner agent:
Skill: scratchpad-planner
args: "issue #{number}: {issue title}
Summary: {brief issue summary}
Key requirements:
{extract key requirements from issue body}
Affected areas (if known):
{mention specific modules/components if issue indicates}
Repository: {owner/repo}
Project context: See CLAUDE.md for module structure and conventions"
The scratchpad-planner agent will:
The agent replaces generic exploration with specialized planning expertise, providing more structured analysis and implementation approach generation.
Technical Breakdown:
Dependency Check:
Generate: SCRATCHPAD_{issue_number}.md
Template Structure:
# {Issue Title} - #{issue_number}
## Issue Details
- **Repository:** {owner/repo}
- **GitHub URL:** {issue_url}
- **State:** {open/closed}
- **Labels:** {labels}
- **Milestone:** {milestone if exists}
- **Assignees:** {assignees}
- **Related Issues:** {linked issues if any}
- Depends on: #{issue_numbers}
- Blocks: #{issue_numbers}
- Related: #{issue_numbers}
## Description
{full issue body from GitHub}
## Acceptance Criteria
{extract task list from issue body, or create from description}
- [ ] {criterion 1}
- [ ] {criterion 2}
- [ ] {criterion 3}
## Branch Strategy
- **Base branch:** main (or develop-ts/develop if exists)
- **Feature branch:** {issue_number}-{slugified-title}
- **Current branch:** {git branch --show-current}
## Implementation Checklist
### Setup
- [ ] Fetch latest from base branch
- [ ] Create and checkout feature branch
### Implementation Tasks
{Break down into atomic commits - each should be independently reviewable}
- [ ] {First atomic task with clear scope}
- Files affected: {list}
- Why: {brief rationale}
- [ ] {Second atomic task}
- Files affected: {list}
- Why: {brief rationale}
{Continue with granular breakdown...}
### Quality Checks
- [ ] Run linter/type checker
- [ ] Execute relevant tests
- [ ] Self-review for code quality
- [ ] Verify acceptance criteria met
### Documentation
- [ ] Update relevant README/docs (if applicable)
- [ ] Add inline comments for complex logic (if applicable)
## Technical Notes
### Architecture Considerations
{Any architectural decisions to consider}
{Module boundaries to respect}
{Integration points to handle}
### Implementation Approach
{High-level strategy for solving the problem}
{Why this approach vs alternatives}
### Potential Challenges
{Known complexity areas}
{Technical debt to navigate}
{Performance considerations}
## Questions/Blockers
### Clarifications Needed
{List any unclear requirements}
{Ambiguities in issue description}
### Blocked By
{List any dependencies not yet complete - reference issue numbers}
### Assumptions Made
{Document assumptions if requirements unclear}
### Decisions Made
{Populated during Phase 3.5 Interactive Q&A}
{Format: Q: question β A: decision (rationale)}
## Work Log
{This section fills in during execution via /start-work}
{Each work session adds dated entries}
---
**Generated:** {timestamp}
**By:** Issue Setup Skill
**Source:** {github_issue_url}
Scratchpad Quality Guidelines:
Goal: Resolve any questions or ambiguities before starting implementation.
Trigger: If the scratchpad has items in the "Clarifications Needed" section.
Process:
Check for Outstanding Questions:
Present Questions via AskUserQuestion:
For each clarification needed, use the AskUserQuestion tool to get user input:
AskUserQuestion:
question: "{The specific clarification question}"
header: "Clarify"
options:
- label: "{Option A}"
description: "{What this choice means}"
- label: "{Option B}"
description: "{What this choice means}"
- label: "{Option C}" (if applicable)
description: "{What this choice means}"
multiSelect: false (or true if multiple answers valid)
Guidelines for presenting questions:
Update Scratchpad with Decisions: After collecting all answers, update the scratchpad:
a) Add "Decisions Made" section (if not present) under Questions/Blockers:
### Decisions Made
{Timestamp}
**Q: {Original question}**
**A:** {User's answer/decision}
**Rationale:** {Brief explanation of why, if provided}
b) Remove resolved items from "Clarifications Needed"
c) Update relevant sections if decisions affect:
Confirm Resolution: Display summary of decisions made:
β Resolved {N} clarifications:
1. {Question summary} β {Decision}
2. {Question summary} β {Decision}
...
π SCRATCHPAD updated with decisions.
Example Interaction:
π SCRATCHPAD_42.md has 3 clarifications that need resolution before proceeding.
[AskUserQuestion 1/3]
Question: "Should we keep commands as aliases during the transition to skills?"
Header: "Migration"
Options:
- "Keep as thin wrappers" - Commands remain but delegate to skills
- "Remove immediately" - Clean break, skills only
- "Decide per-command" - Evaluate each command individually
[User selects: "Keep as thin wrappers"]
[AskUserQuestion 2/3]
Question: "How should prime-session be handled?"
Header: "Behavior"
Options:
- "Convert to auto-invoke skill" - Activates when entering new repo
- "Keep as explicit command" - User must invoke manually
- "Remove entirely" - Claude reads CLAUDE.md automatically anyway
[User selects: "Keep as explicit command"]
...
β Resolved 3 clarifications:
1. Migration strategy β Keep commands as thin wrappers
2. prime-session behavior β Keep as explicit command
3. ...
π SCRATCHPAD_42.md updated with decisions.
Proceeding to branch creation...
Skip Conditions:
Goal: Get explicit user approval of the implementation plan before preparing the workspace.
This mirrors Claude's EnterPlanMode/ExitPlanMode approval pattern β the user reviews and signs off on the plan before any workspace changes.
Present Plan Summary:
π SCRATCHPAD_{issue_number}.md ready for review:
{X} implementation tasks
{Y} quality checks
{Z} decisions resolved
Key changes:
- {Brief summary of major tasks}
Request Approval:
AskUserQuestion:
question: "Approve this implementation plan?"
header: "Plan"
options:
- label: "Approve"
description: "Plan looks good, create branch and proceed"
- label: "Revise plan"
description: "Re-run planning with adjusted focus"
- label: "Let me review"
description: "I'll read the scratchpad first, then decide"
Handle Response:
This phase is NOT skippable. The user must explicitly approve before workspace preparation begins.
Branch Creation:
Detect base branch:
# Check what branches exist
git fetch origin
# Prefer in this order:
# 1. develop-ts (if exists)
# 2. develop (if exists)
# 3. main (default)
git branch -r | grep -E 'origin/(develop-ts|develop|main)'
Create feature branch:
# Generate branch name from issue
# Format: {issue_number}-{slugified-title}
# Example: 42-implement-fact-batching
git branch {issue-number}-{slugified-title} origin/{base-branch}
# Don't checkout yet - let operator decide when to switch
Confirm creation:
git branch --list {branch-name}
Final Output:
Display concise summary:
β Issue #{issue_number} analyzed and prepared
π SCRATCHPAD_{issue_number}.md created with:
- {X} implementation tasks
- {Y} quality checks
- {Z} decisions made (via Q&A)
πΏ Branch '{issue-number}-{slugified-title}' created from {base-branch}
π GitHub Issue: {issue_url}
π Ready to begin work:
git checkout {branch-name}
# Then start implementation
Note: If clarifications were resolved in Phase 3.5, the scratchpad now contains confirmed decisions rather than open questions. All ambiguities should be resolved before reaching this point.
Component Context:
Contract Context:
If GitHub issue doesn't exist:
If issue lacks description or clear scope:
If feature branch already exists:
If can't access repository:
Flows to:
/start-work {issue_number} - Begin execution from scratchpad/commit - Make atomic commits as checklist progressesReceives context from:
/prime-session - Current development prioritiesBefore Scratchpad Creation: If issue is complex or ambiguous, ask:
After Scratchpad Created (Phase 3.6): Explicit approval required β handled by Phase 3.6 Plan Approval step. User must approve, request revision, or review before branch creation proceeds.
Before Branch Creation: Confirm readiness:
A successful issue setup produces:
β Complete context: All issue details captured β Clear plan: Implementation steps are atomic and logical β Identified risks: Challenges flagged upfront β Ready workspace: Branch created, scratchpad prepared β Operator confidence: Developer knows exactly what to build
The scratchpad should be so clear that another developer could pick it up and execute it.
If the issue analysis reveals a complex implementation, suggest entering plan mode:
Triggers for EnterPlanMode:
Suggestion:
This issue appears complex ({reason}). Would you like me to enter
plan mode to design the implementation approach before we proceed?
Version: 1.1.0 Last Updated: 2025-12-31 Maintained By: Escapement Changelog: