Mika
Claude Pilot development workflow with quality gates
Claude CodeGeneric
---
name: mika
description: Claude Pilot development workflow with quality gates
argument-hint: "[feature description]"
disable-model-invocation: true
---
<!-- SCOPE: claude-pilot repo ONLY. Do NOT copy this to the meta-repo or other sub-repos. -->
Run these steps in order. Do not do anything else. Do not stop between steps — complete every step through to the end.
**Issue linking:** If `$ARGUMENTS` (after stripping any `branch:` prefix) starts with `#` followed by a number (e.g. `#42`) or is just a number, treat it as a GitHub issue reference. Run `gh issue view <number> --repo senara-solutions/claude-pilot --json number,title,body,labels` to fetch the issue details, then use the issue title and body as the feature description for the planning step. Remember the issue number for the PR step.
## Worktree isolation
Before running the pipeline, set up an isolated worktree:
1. **Parse branch:** Determine the branch name using this priority order (first match wins):
a. **Explicit `branch:` prefix:** If `$ARGUMENTS` starts with `branch:<name>`, extract `<name>` and strip the prefix.
b. **Issue body callout:** If an issue was fetched above, search the issue body for a line matching `> - **Branch:**` followed by a backtick-wrapped branch name. Extract that branch name. This is how pre-planned tickets communicate their branch — **always use it when present**.
c. **Derive from args (deterministic):** Only if (a) and (b) both miss, derive the branch name using this **exact bash recipe** — do not re-derive with the LLM or substitute your own kebab-casing, since redispatches must produce the same slug:
```bash
# Inputs: $ISSUE_NUMBER (optional, set when an issue was fetched), raw title/text
raw="${ISSUE_TITLE:-$ARGUMENTS}"
if printf '%s' "$raw" | grep -qE '^(feat|fix|chore|docs|eval|test|refactor|perf)(\([^)]+\))?: '; then
type=$(printf '%s' "$raw" | sed -nE 's/^([a-z]+)(\([^)]+\))?: .*$/\1/p')
body=$(printf '%s' "$raw" | sed -E 's/^[a-z]+(\([^)]+\))?: *//')
else
type=feat
body="$raw"
fi
slug=$(printf '%s' "$body" | tr '[:upper:]' '[:lower:]' \
| LC_ALL=C sed -E 's/[^a-z0-9]+/-/g; s/^-+//; s/-+$//' \
| cut -c1-45 | sed -E 's/-[^-]*$//; s/-+$//')
if [ -n "${ISSUE_NUMBER:-}" ]; then
BRANCH="${type}/${ISSUE_NUMBER}/${slug}"
else
BRANCH="${type}/${slug}"
fi
```
2. **Skip if no branch or no args:** If there are no arguments (backlog eval mode), skip worktree creation and run the pipeline in the current directory.
3. **Detect existing worktree (MANDATORY):** Run `git rev-parse --git-dir` and `git rev-parse --git-common-dir`. If they differ, you are ALREADY inside a worktree. **STOP worktree setup immediately** — set `CREATED_WORKTREE=false` and proceed directly to the Pipeline section below. Do NOT attempt to create, remove, or modify any worktree. Do NOT clean up or recreate. Just use the current directory as-is.
4. **Sync main:** Run `git fetch origin main:main` to fast-forward local `main` to match remote. This ensures the worktree branches from the latest code. If it fails (e.g., `main` is checked out with uncommitted changes), fall back to `git fetch origin` and use `origin/main` as the base ref in the next step.
5. **Create worktree:** Set `WORKTREE=../.claude/worktrees/<sanitized-branch>/claude-pilot/` (sanitize branch name: replace `/` with `-`). Record `ORIGINAL_DIR=$(pwd)`.
- If the worktree path already exists, remove it first: `git worktree remove --force <WORKTREE>` (ignore errors).
- Try: `git worktree add -b <branch> <WORKTREE> main`
- If that fails (branch already exists): `git worktree add <WORKTREE> <branch>`
- cd into the worktree. Set `CREATED_WORKTREE=true`.
## Pipeline
1. `/ralph-loop "finish all slash commands" --completion-promise "DONE"`
2. `/ce:plan $ARGUMENTS` (if an issue was detected, pass the issue title + body instead of raw arguments)
3. `/ce:work`
4. `/ce:review`
5. `/compound-engineering:resolve_todo_parallel`
6. `/ce:compound`
7. Run `bash scripts/verify-pipeline.sh` to verify pipeline artifacts exist. If it fails, read the error messages to identify missing artifacts, go back and produce them (run `/ce:plan` if no plan doc, `/ce:work` if no source changes), then re-run verification until it passes.
8. Create a PR if one doesn't already exist:
gh pr create --title "
If a GitHub issue was referenced, include `Closes #<number>` in the PR body.
## Cleanup
9. Do NOT remove the worktree — it persists for CI fixes, review feedback, and acceptance testing.
10. Output `<promise>DONE</promise>` when complete
Start with worktree isolation, then step 1.
Maintain Mika?
Let people know it's listed here — add the badge (live metrics, light/dark aware) or a plain link to your README or docs.
[Mika on getagentictools](https://getagentictools.com/loops/senara-solutions-mika?ref=badge) npx agentictools info loops/senara-solutions-mika The second line is the CLI lookup for this page — handy in READMEs and docs.