**Mode Configuration**: This prompt runs in non-interactive environments (e.g., CI/CD, automation scripts).

**Non-Interactive Mode Behavior**:
- DO NOT use `AskUserQuestion` or any interactive tools
- When user input is required, use reasonable defaults (e.g., select the most recently modified change)
- Skip optional confirmation steps, document assumptions made

**Interactive Mode Behavior**:
- Follow the normal interactive flow with user prompts

---

Fast-forward through artifact creation - generate everything needed to start implementation.

**Input**: The current workflow input can be the change name (kebab-case), OR a description of what the user wants to build.

{{#if planningDirectionInstructions}}
## Planning Directions For This Run

{{{planningDirectionInstructions}}}
{{/if}}

**Steps**

1. **If no input provided, use reasonable defaults**

   The current workflow input can be the change name (kebab-case), OR a description of what the user wants to build.

   If `changeDescription` or `changeName` is provided in the input context, use it.

   **In non-interactive mode**:
   - Document the assumption: "No input provided"
   - Continue waiting for user to provide the change description or name

   **In interactive mode**:
   - Ask the user: "What change do you want to work on? Describe what you want to build or fix."
   - From their description, derive a kebab-case name (e.g., "add user authentication" → `add-user-auth`)

   **IMPORTANT**: Do NOT proceed without understanding what the user wants to build.

2. **Create the change directory**
   ```bash
   openspec new change "<name>"
   ```
   This creates a scaffolded change at `openspec/changes/<name>/`.

3. **Get the artifact build order**
   ```bash
   openspec status --change "<name>" --json
   ```
   Parse the JSON to get:
   - `applyRequires`: array of artifact IDs needed before implementation (e.g., `["tasks"]`)
   - `artifacts`: list of all artifacts with their status and dependencies

4. **Create artifacts in sequence until apply-ready**

   Use the **TodoWrite tool** to track progress through the artifacts.

   Loop through artifacts in dependency order (artifacts with no pending dependencies first):

   a. **For each artifact that is `ready` (dependencies satisfied)**:
      - Get instructions:
        ```bash
        openspec instructions <artifact-id> --change "<name>" --json
        ```
      - The instructions JSON includes:
        - `context`: Project background (constraints for you - do NOT include in output)
        - `rules`: Artifact-specific rules (constraints for you - do NOT include in output)
        - `template`: The structure to use for your output file
        - `instruction`: Schema-specific guidance for this artifact type
        - `outputPath`: Where to write the artifact
        - `dependencies`: Completed artifacts to read for context
      - Read any completed dependency files for context
      - Create the artifact file using `template` as the structure
      - Apply `context` and `rules` as constraints - but do NOT copy them into the file
      - **Apply any enabled planning-direction output requirements (use the direction block above and the reference examples below)**
      - Show brief progress: "✓ Created <artifact-id>"

   b. **After creating each artifact, verify enabled planning-direction output**:

      For **proposal.md**:
      - [ ] Are enabled proposal-stage directions represented (for example change maps, interaction flows, or UI prototypes)?

      For **design.md**:
      - [ ] Are enabled design-stage directions represented (for example architecture diagrams, data-flow diagrams, API sequence diagrams, or detailed change inventories)?

      If any enabled direction is missing: **MUST** supplement the artifact before writing it.

   c. **Continue until all `applyRequires` artifacts are complete**
      - After creating each artifact, re-run `openspec status --change "<name>" --json`
      - Check if every artifact ID in `applyRequires` has `status: "done"` in the artifacts array
      - Stop when all `applyRequires` artifacts are done

   d. **If an artifact requires user input** (unclear context):
      - In non-interactive mode: make reasonable assumptions and document them
      - In interactive mode: clarify with the user
      - Then continue with creation

5. **Show final status**
   ```bash
   openspec status --change "<name>"
   ```

**Output**

After completing all artifacts, summarize:
- Change name and location
- List of artifacts created with brief descriptions
- What's ready: "All artifacts created! Ready for implementation."
- Prompt: "Enter the implementation stage to start implementing."

**Artifact Creation Guidelines**

- Follow the `instruction` field from `openspec instructions` for each artifact type
- The schema defines what each artifact should contain - follow it
- Read dependency artifacts for context before creating new ones
- Use the `template` as a starting point, filling in based on context

**Special Note: tasks.md Content Scope**
- tasks.md should focus on business logic and technical implementation tasks
- Should NOT include Git version control operations (git add, git commit, git push)
- See the "tasks.md Content Scope Constraints" section below for detailed rules

### tasks.md Content Scope Constraints

When creating the `tasks.md` artifact, you **MUST** adhere to the following content scope constraints:

**MUST Include**:
- Business logic tasks (code implementation, feature development)
- Technical implementation tasks (component integration, API development)
- Testing tasks (unit tests, integration tests)
- Documentation tasks (updating docs, adding comments)

**MUST NOT Include**:
- Git commit operations (git add, git commit, git push)
- Version control management workflows
- Deployment and release operations

**Exception**:
When the change itself is about modifying Git command logic in prompt templates, Git commands may be referenced as **descriptive content** (e.g., "Locate the git add command in step 5"), not as **operational instructions** (e.g., "Execute git add . && git commit").

**Decision Criteria**:
- If the change's goal is to modify Git command logic in prompts → Descriptive references allowed
- Otherwise → Actual Git operation steps should NOT be included in tasks

**Guardrails**
- Create ALL artifacts needed for implementation (as defined by schema's `apply.requires`)
- Always read dependency artifacts before creating a new one
- If context is critically unclear, ask the user - but prefer making reasonable decisions to keep momentum
- If a change with that name already exists, ask if the user wants to continue it or create a new one
- Verify each artifact file exists after writing before proceeding to the next

---

## Planning Direction Reference Examples

Use this section only as a style reference for directions that are enabled above. These examples are **not** always-on requirements by themselves.

### `change-map` direction

If enabled, `proposal.md` should include a structured code change table, and `design.md` can expand it into a more detailed inventory.

**Example Code Change Table**:
| File Path | Change Type | Change Reason | Impact Scope |
|-----------|-------------|---------------|--------------|
|           |             |               |              |

**Example Detailed Code Change Inventory**:
| File Path | Change Type | Change Description | Affected Module |
|-----------|-------------|-------------------|-----------------|
|           |             |                   |                 |

### `prototype` direction

If enabled and the proposal changes UI, include an ASCII interface sketch in `proposal.md`.

**Example ASCII UI Prototype**:
```
┌─────────────────────────────────────────┐
│ User Login                         [×] │
├─────────────────────────────────────────┤
│  Email Address *                       │
│ ┌─────────────────────────────────────┐ │
│ │ user@example.com                   │ │
│ └─────────────────────────────────────┘ │
│  Password *                            │
│ ┌─────────────────────────────────────┐ │
│ │ ••••••••••••••••••••••••••••••••  │ │
│ └─────────────────────────────────────┘ │
│            [Login] [Register]            │
└─────────────────────────────────────────┘
```

### `flowchart` direction

If enabled, include Mermaid flowcharts when they help explain interaction steps or design data flow.

**Example Mermaid Interaction Flow**:
```mermaid
sequenceDiagram
    participant U as User
    participant UI as Login Screen
    participant API as Backend API
    participant DB as Database

    U->>UI: Click login button
    UI->>API: POST /api/auth/login
    API->>DB: Verify credentials
    DB-->>API: Return user info
    API-->>UI: Return auth result
```

**Example Data Flow Diagram**:
```mermaid
flowchart TD
    A[User Input] --> B[Validate Request]
    B -->|Validation Failed| C[Return Error]
    B -->|Validation Success| D[Process Business Logic]
    D --> E[Update Database]
    E --> F[Return Success Response]
```

### `architecture` direction

If enabled, include a component or module hierarchy diagram in `design.md`.

**Example Component Architecture**:
```
Component Hierarchy
├── ParentComponent (parent)
│   ├── ChildComponentA (child A)
│   │   └── GrandChildComponent (grandchild)
│   └── ChildComponentB (child B)
```

### `sequence` direction

If enabled, include an API or cross-service sequence diagram in `design.md`.

**Example API Call Sequence Diagram**:
```mermaid
sequenceDiagram
    participant Client as Client
    participant API as API Gateway
    participant Service as Business Service
    participant DB as Database

    Client->>API: POST /api/resource
    API->>Service: Call business logic
    Service->>DB: Query/update data
    DB-->>Service: Return data
    Service-->>API: Return processing result
    API-->>Client: Return response
```

### `tasks.md`

- No mandatory visualization requirements (task list format is acceptable)
