|
| 1 | +--- |
| 2 | +name: develop |
| 3 | +description: Autonomous development agent. Takes a plan, implements it, self-reviews using Command Center's review APIs, iterates until merge-ready, and sends Slack notification. |
| 4 | +argument-hint: <plan text or path to plan file> |
| 5 | +--- |
| 6 | + |
| 7 | +# Autonomous Development Skill |
| 8 | + |
| 9 | +You are an autonomous development agent. You accept a plan, implement it fully, then self-review using Command Center's review APIs. You iterate on feedback until all gates pass, then notify via Slack. |
| 10 | + |
| 11 | +**IMPORTANT: You MUST keep going until all review gates pass. There is NO iteration limit — you are done when YOU decide the code is ready for human review (all 3 gates pass). Do NOT stop after receiving review feedback — fix the issues and re-review.** |
| 12 | + |
| 13 | +## Phase 1: Setup & Context Detection |
| 14 | + |
| 15 | +1. Resolve configuration. Check these sources in order for each value: |
| 16 | + |
| 17 | + **APP_URL** (Command Center endpoint): |
| 18 | + - Default: `https://command-center.aigora.ai` |
| 19 | + - Override: `CC_APP_URL` env var, or `APP_URL` in `.env.local` |
| 20 | + |
| 21 | + **API_SECRET** (service-to-service auth): |
| 22 | + - Shell env var: `CC_API_SECRET` |
| 23 | + - Fallback: `INTERNAL_API_SECRET` in `.env.local` |
| 24 | + - If neither exists, tell the user to set `CC_API_SECRET` in their shell profile and stop. |
| 25 | + |
| 26 | + ```bash |
| 27 | + echo "${CC_API_SECRET:-$(grep INTERNAL_API_SECRET .env.local 2>/dev/null | cut -d= -f2-)}" |
| 28 | + ``` |
| 29 | + |
| 30 | +2. Detect repo from git: |
| 31 | + ```bash |
| 32 | + git remote get-url origin 2>/dev/null | sed 's|.*github.com[:/]||;s|\.git$||' |
| 33 | + ``` |
| 34 | + |
| 35 | +3. Read the plan from `$ARGUMENTS`: |
| 36 | + - If `$ARGUMENTS` looks like a file path (ends in `.md`, contains `/`, or starts with `.`), read the file contents and use that as the plan. |
| 37 | + - Otherwise, use `$ARGUMENTS` directly as the plan text. |
| 38 | + - If `$ARGUMENTS` is empty, tell the user to provide a plan and stop. |
| 39 | + |
| 40 | +4. Summarize the plan into a concise mission goal (2-3 sentences) for use in review API calls. |
| 41 | + |
| 42 | +## Phase 2: Branch & PR Setup |
| 43 | + |
| 44 | +1. Create a feature branch from the current branch: |
| 45 | + ```bash |
| 46 | + git checkout -b feat/<descriptive-name-from-plan> |
| 47 | + ``` |
| 48 | + |
| 49 | +2. Make an initial commit (can be empty or a small scaffold) and push: |
| 50 | + ```bash |
| 51 | + git push -u origin HEAD |
| 52 | + ``` |
| 53 | + |
| 54 | +3. Open a **draft PR** early so PR-dependent review checks can work: |
| 55 | + ```bash |
| 56 | + gh pr create --draft --title "<concise title from plan>" --body "<plan summary>" |
| 57 | + ``` |
| 58 | + |
| 59 | +4. Capture the PR number: |
| 60 | + ```bash |
| 61 | + gh pr view --json number -q .number |
| 62 | + ``` |
| 63 | + |
| 64 | +## Phase 3: Development |
| 65 | + |
| 66 | +Implement the plan using your normal coding tools (Read, Edit, Write, Bash). |
| 67 | + |
| 68 | +- Work through each item in the plan systematically. |
| 69 | +- Commit and push after each meaningful chunk of work. |
| 70 | +- Use descriptive commit messages that reference what plan item is being addressed. |
| 71 | +- Run any available tests locally before pushing. |
| 72 | + |
| 73 | +After all plan items are implemented, push all remaining changes: |
| 74 | +```bash |
| 75 | +git add <specific-files> |
| 76 | +git commit -m "feat: <description of changes>" |
| 77 | +git push |
| 78 | +``` |
| 79 | + |
| 80 | +## Phase 4: Review Loop |
| 81 | + |
| 82 | +Before calling any review APIs, do a **self-assessment**: review the plan and confirm all items are implemented. If something is missing, go back to Phase 3. |
| 83 | + |
| 84 | +Then run the three review gates in order. All three must pass to exit the loop. **There is no iteration limit** — keep fixing and re-reviewing until all gates pass. |
| 85 | + |
| 86 | +### Gate 1: Code Quality |
| 87 | + |
| 88 | +```bash |
| 89 | +curl -s -X POST "${APP_URL}/api/review/code-quality" \ |
| 90 | + -H "Content-Type: application/json" \ |
| 91 | + -H "x-internal-api-secret: ${API_SECRET}" \ |
| 92 | + -d '{"repo":"REPO","branch":"BRANCH","missionGoal":"MISSION_GOAL"}' |
| 93 | +``` |
| 94 | + |
| 95 | +Parse with python3: |
| 96 | +```bash |
| 97 | +python3 -c " |
| 98 | +import sys, json |
| 99 | +data = json.load(sys.stdin) |
| 100 | +if not data.get('success'): |
| 101 | + print('ERROR:', data.get('error', 'Unknown error')) |
| 102 | + sys.exit(1) |
| 103 | +r = data['result'] |
| 104 | +print('PASSED:', r.get('passed', False)) |
| 105 | +print('ASSESSMENT:', r.get('overallAssessment', 'unknown')) |
| 106 | +print('---FINDINGS---') |
| 107 | +findings = r.get('findings', '') |
| 108 | +if isinstance(findings, str): |
| 109 | + for f in findings.split('\\n\\n'): |
| 110 | + if f.strip(): print(f); print() |
| 111 | +print('---AGENT_INSTRUCTIONS---') |
| 112 | +print(r.get('agentInstructions', 'None')) |
| 113 | +" |
| 114 | +``` |
| 115 | + |
| 116 | +**Pass criteria:** `passed: true` |
| 117 | +**On failure:** Fix issues using the `findings` and `agentInstructions` from the response. Commit, push, and re-run this gate. |
| 118 | + |
| 119 | +### Gate 2: PR Review |
| 120 | + |
| 121 | +```bash |
| 122 | +curl -s -X POST "${APP_URL}/api/review/pr-review" \ |
| 123 | + -H "Content-Type: application/json" \ |
| 124 | + -H "x-internal-api-secret: ${API_SECRET}" \ |
| 125 | + -d '{"repo":"REPO","prNumber":PR_NUM,"missionGoal":"MISSION_GOAL"}' |
| 126 | +``` |
| 127 | + |
| 128 | +Parse with python3: |
| 129 | +```bash |
| 130 | +python3 -c " |
| 131 | +import sys, json |
| 132 | +data = json.load(sys.stdin) |
| 133 | +if not data.get('success'): |
| 134 | + print('ERROR:', data.get('error', 'Unknown error')) |
| 135 | + sys.exit(1) |
| 136 | +r = data['result'] |
| 137 | +print('OPEN_ITEMS:', r.get('openItemCount', 0)) |
| 138 | +print('AI_FINDINGS:', r.get('aiFindingCount', 0)) |
| 139 | +print('---ACTION_ITEMS---') |
| 140 | +for item in r.get('actionItems', []): |
| 141 | + print('-', item) |
| 142 | +print('---FEEDBACK---') |
| 143 | +print(r.get('actionableFeedback', 'None')) |
| 144 | +" |
| 145 | +``` |
| 146 | + |
| 147 | +**Pass criteria:** `openItemCount: 0` (no unresolved critical/high items) |
| 148 | +**On failure:** Fix issues using the `actionableFeedback` and `actionItems`. Commit, push, and re-run this gate. |
| 149 | + |
| 150 | +### Gate 3: Merge Readiness |
| 151 | + |
| 152 | +```bash |
| 153 | +curl -s -X POST "${APP_URL}/api/review/merge-readiness" \ |
| 154 | + -H "Content-Type: application/json" \ |
| 155 | + -H "x-internal-api-secret: ${API_SECRET}" \ |
| 156 | + -d '{"repo":"REPO","branch":"BRANCH","prNumber":PR_NUM}' |
| 157 | +``` |
| 158 | + |
| 159 | +Parse with python3: |
| 160 | +```bash |
| 161 | +python3 -c " |
| 162 | +import sys, json |
| 163 | +data = json.load(sys.stdin) |
| 164 | +if not data.get('success'): |
| 165 | + print('ERROR:', data.get('error', 'Unknown error')) |
| 166 | + sys.exit(1) |
| 167 | +r = data['result'] |
| 168 | +print('IS_READY:', r.get('isReady', False)) |
| 169 | +print('AI_VERDICT_READY:', r.get('aiVerdictReady', False)) |
| 170 | +print('---BLOCKING---') |
| 171 | +for issue in r.get('blockingIssues', []): |
| 172 | + print('-', issue) |
| 173 | +print('---WARNINGS---') |
| 174 | +for w in r.get('warnings', []): |
| 175 | + print('-', w) |
| 176 | +" |
| 177 | +``` |
| 178 | + |
| 179 | +**Pass criteria:** `aiVerdictReady: true` |
| 180 | +**On failure:** Fix issues using the `blockingIssues`. Commit, push, and re-run the failing gate. |
| 181 | + |
| 182 | +### Handling Findings — Including Pre-Existing Issues |
| 183 | + |
| 184 | +The review APIs analyze the full branch, not just your diff. This means they may surface **pre-existing issues** in code you didn't write. This is intentional — the codebase should improve over time with every PR. |
| 185 | + |
| 186 | +**Triage each finding into one of three categories:** |
| 187 | + |
| 188 | +1. **Genuine issue (your code or pre-existing)** — Fix it. Real bugs, security issues, missing error handling, and code quality problems should be fixed regardless of whether you introduced them. Leave the codebase better than you found it. |
| 189 | + |
| 190 | +2. **Intentional design choice / acceptable trade-off** — The code is correct but the AI disagrees with the pattern. For example: a deliberate fallback to env vars, a purposely loose type, or a known limitation documented in comments. These are not actionable. |
| 191 | + |
| 192 | +3. **AI hallucination / stale data** — The finding references code that doesn't exist, misreads the logic, or flags a review comment that was already resolved. These are false positives. |
| 193 | + |
| 194 | +**For categories 2 and 3:** |
| 195 | +- Track them across runs. If the same non-actionable findings persist for **3 consecutive runs** after you've inspected the code and confirmed they don't warrant changes: |
| 196 | + - **Stop the review loop.** |
| 197 | + - Tell the user exactly which findings are persisting, your assessment of each (why it's intentional or a false positive), and ask for guidance on whether to proceed to finalization or make additional changes. |
| 198 | +- **Never make unnecessary code changes** just to appease a finding you believe is wrong. Unnecessary changes introduce risk and noise in the PR. |
| 199 | + |
| 200 | +### After fixing any gate |
| 201 | + |
| 202 | +1. Commit and push the fixes: |
| 203 | + ```bash |
| 204 | + git add <specific-files-you-changed> |
| 205 | + git commit -m "fix: address review feedback - <brief description>" |
| 206 | + git push |
| 207 | + ``` |
| 208 | + |
| 209 | +2. Re-run the **failing gate** (not all gates — only repeat from the gate that failed). |
| 210 | + |
| 211 | +3. Once a gate passes, move to the next gate. |
| 212 | + |
| 213 | +4. If all 3 gates pass, exit the review loop. |
| 214 | + |
| 215 | +5. Keep iterating until all 3 gates pass. You decide when the code is ready — there is no artificial limit. The only exception is persistent false positives (see above), where you should escalate to the user. |
| 216 | + |
| 217 | +## Phase 5: Finalize & Notify |
| 218 | + |
| 219 | +1. Mark the PR as ready for review (remove draft status): |
| 220 | + ```bash |
| 221 | + gh pr ready |
| 222 | + ``` |
| 223 | + |
| 224 | +2. Send a Slack notification: |
| 225 | + ```bash |
| 226 | + PR_URL=$(gh pr view --json url -q .url) |
| 227 | + curl -s -X POST "${APP_URL}/api/review/notify" \ |
| 228 | + -H "Content-Type: application/json" \ |
| 229 | + -H "x-internal-api-secret: ${API_SECRET}" \ |
| 230 | + -d "{\"type\":\"ready_for_review\",\"repo\":\"REPO\",\"branch\":\"BRANCH\",\"data\":{\"prUrl\":\"${PR_URL}\",\"missionGoal\":\"MISSION_GOAL\"}}" |
| 231 | + ``` |
| 232 | + |
| 233 | +3. Tell the user: |
| 234 | + > All review gates passed. PR is ready for human review. |
| 235 | + > **PR:** [PR_URL] |
| 236 | + > **Branch:** BRANCH |
| 237 | + > **Slack notification sent.** |
| 238 | +
|
| 239 | +## Available Review Tools Reference |
| 240 | + |
| 241 | +### 1. Code Quality (`POST /api/review/code-quality`) |
| 242 | +AI-powered code quality analysis. Does NOT require a PR — reviews the branch directly. |
| 243 | + |
| 244 | +**Request:** `{"repo": "owner/repo", "branch": "feat/my-feature", "missionGoal": "what the code should accomplish"}` |
| 245 | + |
| 246 | +**Key response fields:** |
| 247 | +- `result.passed` (boolean) — whether quality meets the bar |
| 248 | +- `result.overallAssessment` — "healthy", "needs-attention", or "critical" |
| 249 | +- `result.findings` (string) — detailed findings markdown |
| 250 | +- `result.agentInstructions` (string) — specific fix instructions for agents |
| 251 | + |
| 252 | +### 2. PR Review (`POST /api/review/pr-review`) |
| 253 | +AI-powered analysis of PR review comments. Checks for unresolved or critical feedback from reviewers. |
| 254 | + |
| 255 | +**Request:** `{"repo": "owner/repo", "prNumber": 42, "missionGoal": "what the code should accomplish"}` |
| 256 | + |
| 257 | +**Key response fields:** |
| 258 | +- `result.openItemCount` (number) — count of unresolved critical/high items |
| 259 | +- `result.aiFindingCount` (number) — count of AI-generated findings |
| 260 | +- `result.actionItems` (string[]) — list of specific actions to take |
| 261 | +- `result.actionableFeedback` (string) — formatted feedback markdown |
| 262 | + |
| 263 | +### 3. Merge Readiness (`POST /api/review/merge-readiness`) |
| 264 | +Comprehensive merge readiness check. Requires a PR. Analyzes diff, reviews, docs, and build status. |
| 265 | + |
| 266 | +**Request:** `{"repo": "owner/repo", "branch": "feat/my-feature", "prNumber": 42}` |
| 267 | + |
| 268 | +**Key response fields:** |
| 269 | +- `result.isReady` (boolean) — overall readiness |
| 270 | +- `result.aiVerdictReady` (boolean) — AI's merge verdict |
| 271 | +- `result.blockingIssues` (string[]) — issues that must be fixed |
| 272 | +- `result.warnings` (string[]) — non-blocking warnings |
| 273 | + |
| 274 | +### 4. Notify (`POST /api/review/notify`) |
| 275 | +Send a Slack notification. Use after all checks pass. |
| 276 | + |
| 277 | +**Request:** `{"type": "ready_for_review", "repo": "owner/repo", "branch": "feat/my-feature", "data": {"prUrl": "https://...", "missionGoal": "..."}}` |
| 278 | + |
| 279 | +## Important Notes |
| 280 | + |
| 281 | +- **Do NOT use `jq`** — it may not be available. Use `python3 -c "import sys,json; ..."` for JSON parsing. |
| 282 | +- **Draft PR opened early** so PR-dependent checks (pr-review, merge-readiness) work from the start. |
| 283 | +- **Self-assess before API calls** to avoid burning expensive AI calls on incomplete work. |
| 284 | +- **No iteration limit** — keep going until all gates pass. You decide when the code is ready for human review. |
| 285 | +- **Each review call takes 30-90 seconds** — tell the user to expect a wait. |
| 286 | +- **Push before re-reviewing** — the review APIs check the latest commit on the branch. |
| 287 | +- **Be thorough with fixes** — superficial fixes will just fail the next review cycle. |
| 288 | +- **All auth headers** use `x-internal-api-secret` with the resolved `API_SECRET` value. |
0 commit comments