|
| 1 | +--- |
| 2 | +name: implement-command-spec |
| 3 | +description: Orchestrate and verify command-spec Oz runs for Linear tickets. Starts an implementation run using the add-command-spec skill, verifies all edited/created generators have meaningful screenshots, and retries with follow-up runs until validation passes. Use this skill whenever you need to implement and fully validate a command-spec Linear ticket end-to-end, or when a user provides a Linear ticket that involves adding or modifying command completions in the command-signatures repo. |
| 4 | +--- |
| 5 | + |
| 6 | +# implement-command-spec |
| 7 | + |
| 8 | +You are an orchestration agent managing the full lifecycle of a command-spec ticket: implementation, screenshot verification, and follow-up correction runs. You receive a Linear ticket URL or ID and drive it to completion autonomously. |
| 9 | + |
| 10 | +## Prerequisites |
| 11 | + |
| 12 | +- `gh` CLI (authenticated, with access to `warpdotdev/command-signatures`) |
| 13 | +- Linear MCP server connected |
| 14 | + |
| 15 | +## Constants |
| 16 | + |
| 17 | +- **Environment ID**: `Z0IIFcJio9DgsLd71HqTvY` (Command completions environment). |
| 18 | +- **Skill**: `warpdotdev/command-signatures:add-command-spec` |
| 19 | +- **Max verification cycles**: 4 (initial run + up to 3 follow-ups) |
| 20 | +- **Max failure retries per run**: 2 (so up to 3 attempts per run before giving up) |
| 21 | +- **Poll interval**: 30 seconds, exponential backoff to at most 480 seconds (8 minutes) |
| 22 | + |
| 23 | +## Phase 1: Extract ticket info |
| 24 | + |
| 25 | +Use the Linear MCP `get_issue` tool to fetch the ticket. Record: |
| 26 | +- The ticket identifier (e.g. `APP-3478`) |
| 27 | +- The ticket title and description — you will need these to construct follow-up prompts later. |
| 28 | + |
| 29 | +## Phase 2: Start the implementation run |
| 30 | + |
| 31 | +Spawn an agent with computer use enabled. |
| 32 | +- In remote environments, use <ENVIRONMENT_ID>. |
| 33 | +- Prompt the agent with the full "warpdotdev/command-signatures:add-command-spec" skill, along with the following instructions: |
| 34 | +"Use the add_command_spec skill to address this linear ticket: <LINEAR_TICKET>. Screenshots should be included as images in the PR description following the upload process, or posted to the Linear issue and linked to in the GitHub PR description if that's not possible." |
| 35 | + |
| 36 | +Once the agent has started, note its run ID and session links, so that they can reported back to the user. |
| 37 | + |
| 38 | +## Phase 3: Handle the spawned agent |
| 39 | + |
| 40 | +When the agent reaches a terminal state: |
| 41 | +- If it **succeeded**: Proceed to Phase 4. |
| 42 | +- If it **failed**: Inspect the status message in the output. |
| 43 | + - If it contains **"Environment setup failed"**, this is a configuration error. **Stop immediately** and report the error — do not retry. |
| 44 | + - For any other failure, restart the run by repeating Phase 2. You may retry up to 2 additional times (3 total attempts per run). If all attempts fail, stop and report the failure with the last error message. |
| 45 | + |
| 46 | +## Phase 4: Discover the PR and identify generators |
| 47 | + |
| 48 | +### Find the PR |
| 49 | + |
| 50 | +The run output includes an **Artifacts** section with the PR reference, branch name, and link: |
| 51 | + |
| 52 | +``` |
| 53 | +Artifacts: |
| 54 | + PR: command-signatures #233 |
| 55 | + Branch: app-3478/command-spec-kubectl-kubeconfig |
| 56 | + Link: https://github.com/warpdotdev/command-signatures/pull/233 |
| 57 | +``` |
| 58 | + |
| 59 | +If artifacts are missing, fall back to searching: |
| 60 | + |
| 61 | +```sh |
| 62 | +gh pr list --repo warpdotdev/command-signatures --state open --json number,title,headRefName,url |
| 63 | +``` |
| 64 | + |
| 65 | +Match by ticket identifier in the branch name or PR title. |
| 66 | + |
| 67 | +### Identify generators from the diff |
| 68 | + |
| 69 | +Fetch the diff: |
| 70 | + |
| 71 | +```sh |
| 72 | +gh pr diff <PR_NUMBER> --repo warpdotdev/command-signatures |
| 73 | +``` |
| 74 | + |
| 75 | +Look for changes in two locations: |
| 76 | +- **Generator source files**: `command-signatures/src/generators/<command>.rs` — each file may define multiple generator functions (e.g. `users_generator`, `services_generator`). A single file change can mean multiple generators need verification. |
| 77 | +- **JSON specs**: `json/<command>.json` — look for `generatorName` references to identify which generators are being wired up. |
| 78 | + |
| 79 | +Build a list of every distinct generator that was added or modified. Include generator function names when identifiable from the diff, not just file paths — this precision matters for screenshot matching later. |
| 80 | + |
| 81 | +Also check the PR description for an explicit summary of what was added; the add-command-spec skill often lists generators there. |
| 82 | + |
| 83 | +## Phase 5: Validate screenshots |
| 84 | + |
| 85 | +For each generator, determine whether a valid screenshot exists that proves it works. |
| 86 | + |
| 87 | +### 5a: Collect screenshots from all sources |
| 88 | + |
| 89 | +**GitHub PR description:** |
| 90 | +```sh |
| 91 | +gh pr view <PR_NUMBER> --repo warpdotdev/command-signatures --json body -q '.body' |
| 92 | +``` |
| 93 | + |
| 94 | +**GitHub PR comments:** |
| 95 | +```sh |
| 96 | +gh pr view <PR_NUMBER> --repo warpdotdev/command-signatures --json comments -q '.comments[].body' |
| 97 | +``` |
| 98 | + |
| 99 | +Extract image URLs from both (markdown `` or `<img src="URL">` tags). |
| 100 | + |
| 101 | +**Linear issue**: Use the Linear MCP `get_issue` tool, then `extract_images` on the description markdown. |
| 102 | + |
| 103 | +**Linear issue comments**: Use the Linear MCP `list_comments` tool, then `extract_images` on each comment body. |
| 104 | + |
| 105 | +### 5b: Analyze each screenshot |
| 106 | + |
| 107 | +For each image URL found: |
| 108 | + |
| 109 | +1. Download it: |
| 110 | + ```sh |
| 111 | + curl -sL "<IMAGE_URL>" -o /tmp/screenshot_N.png |
| 112 | + ``` |
| 113 | +2. View the downloaded image with `read_files` to trigger vision analysis. |
| 114 | +3. Determine: |
| 115 | + - **Which generator(s)** does this screenshot demonstrate? Look for: the command being typed, visible completions dropdown entries, flags or subcommands in the input, filenames or paths that indicate which generator was invoked. |
| 116 | + - **Is the screenshot meaningful?** |
| 117 | + - It must show the completions menu (a dropdown next to the cursor) with real, generator-produced entries. |
| 118 | + - A screenshot that shows the command typed but no completions appearing is **not valid**. |
| 119 | + - A screenshot showing an empty completions menu or only static (non-generator) completions is **not valid**. |
| 120 | + - Each generator needs at least one screenshot showing it producing non-trivial output. |
| 121 | + |
| 122 | +### 5c: Build the verification map |
| 123 | + |
| 124 | +Create a mapping: `generator → valid screenshot(s)`. Any generator with zero valid screenshots is **unverified**. |
| 125 | + |
| 126 | +If all generators are verified, skip to Phase 7. |
| 127 | + |
| 128 | +## Phase 6: Follow-up runs |
| 129 | + |
| 130 | +When generators still lack valid screenshots: |
| 131 | + |
| 132 | +### 6a: Update Linear status |
| 133 | + |
| 134 | +If the ticket was moved to "In Review", move it back to "In Progress" using the Linear MCP `save_issue` tool: |
| 135 | + |
| 136 | +```json |
| 137 | +{ "id": "<TICKET_ID>", "state": "In Progress" } |
| 138 | +``` |
| 139 | + |
| 140 | +### 6b: Construct the follow-up prompt |
| 141 | + |
| 142 | +Read `references/follow-up-prompt-template.md` and fill in the placeholders with: |
| 143 | +- The ticket description from Phase 1 |
| 144 | +- The branch name and PR URL from Phase 4 |
| 145 | +- The specific list of unverified generators and what each should produce |
| 146 | +- Context about what was already verified vs. what's still missing |
| 147 | + |
| 148 | +### 6c: Start the follow-up run |
| 149 | + |
| 150 | +Spawn another agent with computer use enabled. |
| 151 | +- In remote environments, use <ENVIRONMENT_ID>. |
| 152 | +- Prompt the agent with the full "warpdotdev/command-signatures:add-command-spec and the <CONSTRUCTED_FOLLOW_UP_PROMPT>. |
| 153 | + |
| 154 | +As before, once the agent has started, note its run ID and session links, so that they can be sent back to the user later. |
| 155 | + |
| 156 | +### 6d: Monitor and re-validate |
| 157 | + |
| 158 | +Repeat Phases 3–5 for the follow-up run. The same failure retry limits apply per run. |
| 159 | + |
| 160 | +This verification loop may repeat up to 3 more times after the initial cycle (4 total verification cycles). If generators still lack valid screenshots after all cycles, proceed to Phase 7 and report which remain unverified. |
| 161 | + |
| 162 | +## Phase 7: Completion |
| 163 | + |
| 164 | +### All generators verified |
| 165 | +- Advance the Linear ticket's status to "In Review" via `save_issue`. |
| 166 | +- Report success in a Linear comment: the PR URL, the verified generators, and how many cycles it took. Include links and run IDs for each spawned agent for traceability. |
| 167 | + |
| 168 | +### Some generators unverified after all attempts |
| 169 | +- Leave the Linear ticket in "In Progress". |
| 170 | +- Edit the Linear ticket description which generators still need screenshots, the PR URL, what succeeded, and any patterns you noticed (e.g. a generator that never produces output may have a more fundamental testing limitation). |
0 commit comments