/metaswarm:setup runs instead · from metaswarm
Interactive project setup for metaswarm that detects your stack, asks targeted questions, and writes project-local files including instruction files and coverage configuration.
This skill never runs in Claude Code
It ships in metaswarm at skills/, but /metaswarm:setup (a command, or a skill Claude Code finds first) has the same name: typing it, or Claude choosing it, runs that one instead.
Interactive setup for metaswarm. Detects your stack, asks targeted questions, writes project-local files, and creates platform-appropriate instruction files and command shims. Replaces both npx metaswarm init and the old /metaswarm-setup command.
After Phase 2 (user questions), determine the correct coverage command from the detection results, then run this Bash command:
PLUGIN_ROOT="${PLUGIN_ROOT:-${CLAUDE_PLUGIN_ROOT:-${extensionPath:-}}}"
if [ -z "$PLUGIN_ROOT" ]; then
setup_script="$(find "${CODEX_HOME:-$HOME/.codex}/plugins/cache" -path '*/metaswarm/*/lib/setup-mandatory-files.sh' -print -quit 2>/dev/null)"
if [ -n "$setup_script" ]; then
PLUGIN_ROOT="$(cd "$(dirname "$setup_script")/.." && pwd)"
fi
fi
if [ -z "$PLUGIN_ROOT" ] && [ -f "$(pwd)/lib/setup-mandatory-files.sh" ]; then
PLUGIN_ROOT="$(pwd)"
fi
bash "${PLUGIN_ROOT}/lib/setup-mandatory-files.sh" "$(pwd)" <threshold> "<coverage-command>" --platform <platform> --reconfigure
Where:
<threshold> is the user's chosen percentage (e.g., 100)<coverage-command> is the enforcement command for their test runner:
"pytest --cov --cov-fail-under=<threshold>""pnpm vitest run --coverage""npx jest --coverage""go run .metaswarm/go-coverage-gate.go" (go test has no threshold flag; the script writes this gate program, which runs go test -coverprofile=coverage.out ./... and fails below the thresholds in .coverage-thresholds.json)"cargo tarpaulin --fail-under <threshold>"<platform> is codex, claude, gemini, or all. Prefer:
codex when running in Codex (PLUGIN_ROOT or CODEX_HOME is present, or the user invoked $setup)claude when running in Claude Code (CLAUDE_PLUGIN_ROOT is present, or the setup skill was invoked there)gemini when running in Gemini (extensionPath is present, or the setup skill was invoked there)all only when the user explicitly asks to configure every supported CLI--reconfigure: always pass it from interactive setup, so the user's answers apply even when .coverage-thresholds.json already exists (a re-run, or a first run after npx metaswarm setup copied the template). It updates the thresholds, a --cov-fail-under/--fail-under value in enforcement.command and an old bare go test command, and keeps every other setting. Only the session hook's self-heal omits it, so a silent background run never changes the file.The script handles:
AGENTS.md for Codex, CLAUDE.md for Claude, GEMINI.md for Gemini; appends metaswarm section (or writes new), skips if already present.coverage-thresholds.json — writes at project root with correct thresholds and command (with --reconfigure, updates an existing one). For Go it also writes .metaswarm/go-coverage-gate.go.claude/commands/start-task.md, prime.md, review-design.md, self-reflect.md, pr-shepherd.md, brainstorm.mdThe script outputs JSON with what was created/skipped/warned/errored. Check that "status": "ok", and show the user every entry in warnings (for example an enforcement.command that still embeds the old threshold).
If the script is not available or fails, fall back to writing these files manually with the Write tool. Do NOT skip them.
Use Glob to check if .metaswarm/project-profile.json exists.
Scan the project directory silently using Glob and Read. Do NOT ask the user for any of this information. Detect everything, then present results.
Check for marker files at the project root:
| Marker File | Language |
|---|---|
package.json | Node.js / JavaScript |
tsconfig.json | TypeScript (refines Node.js to TypeScript) |
pyproject.toml OR setup.py OR requirements.txt | Python |
go.mod | Go |
Cargo.toml | Rust |
pom.xml OR build.gradle OR build.gradle.kts | Java |
Gemfile | Ruby |
Makefile (alone, no other markers) | Unknown (ask user) |
If tsconfig.json exists alongside package.json, the language is "TypeScript".
If multiple languages are detected, note all of them but use the primary one (most infrastructure) for command generation.
If no language detected: Use AskUserQuestion to ask the user what language/stack they are using before proceeding.
Node.js/TypeScript — Read package.json and check dependencies + devDependencies:
| Dependency | Framework |
|---|---|
next | Next.js |
nuxt OR nuxt3 | Nuxt |
@angular/core | Angular |
svelte OR @sveltejs/kit | SvelteKit |
react (without next/nuxt) | React |
vue (without nuxt) | Vue |
express | Express |
fastify | Fastify |
hono | Hono |
@nestjs/core | NestJS |
Python — Check pyproject.toml or requirements.txt for: fastapi, django, flask.
Go — Read go.mod for: github.com/gin-gonic/gin (Gin), github.com/labstack/echo (Echo), github.com/gofiber/fiber (Fiber).
If no framework detected, set to null.
| Lock File | Package Manager |
|---|---|
pnpm-lock.yaml | pnpm |
yarn.lock | yarn |
bun.lockb | bun |
package-lock.json | npm |
Default to npm if no lock file found. For non-Node.js, set to null.
Node.js/TypeScript (first match wins):
vitest.config.* or vitest in devDependencies -> vitestjest.config.* or jest in devDependencies -> jestmocha in devDependencies -> mochaPython: Check for [tool.pytest] in pyproject.toml or pytest in dependencies -> pytest (default for Python).
Go: go test (built-in). Rust: cargo test (built-in). Java/Maven: mvn test. Java/Gradle: gradle test.
| Marker | Linter |
|---|---|
.eslintrc* OR eslint.config.* OR eslint in devDependencies | eslint |
biome.json OR @biomejs/biome in devDependencies | biome |
[tool.ruff] in pyproject.toml OR ruff.toml | ruff |
.golangci.yml OR .golangci.yaml | golangci-lint |
.clippy.toml or clippy in Cargo.toml | clippy |
| Marker | Formatter |
|---|---|
.prettierrc* OR prettier in devDependencies | prettier |
biome.json (also formats) | biome |
black in Python deps | black |
[tool.ruff.format] in pyproject.toml | ruff format |
rustfmt.toml OR .rustfmt.toml | rustfmt |
If biome detected as both linter and formatter, report once as "Biome (lint + format)".
| Marker | Type Checker |
|---|---|
tsconfig.json | tsc |
mypy in Python deps OR [tool.mypy] in pyproject.toml | mypy |
pyright in Python deps OR pyrightconfig.json | pyright |
Go (go vet) and Rust (cargo check) have built-in type checking — note but do not list separately.
| Marker | CI System |
|---|---|
.github/workflows/*.yml | GitHub Actions |
.gitlab-ci.yml | GitLab CI |
Jenkinsfile | Jenkins |
.circleci/config.yml | CircleCI |
| Marker | Hook System |
|---|---|
.husky/ | Husky |
.pre-commit-config.yaml | pre-commit |
.lefthook.yml | Lefthook |
After all detection, present findings:
I detected the following about your project:
Language: {language}
Framework: {framework or "None detected"}
Package manager: {package_manager or "N/A"}
Test runner: {test_runner or "None detected"}
Linter: {linter or "None detected"}
Formatter: {formatter or "None detected"}
Type checker: {type_checker or "None detected"}
CI: {ci or "None detected"}
Git hooks: {git_hooks or "None detected"}
Use AskUserQuestion to ask ONLY questions relevant based on detection. 3-5 questions maximum. Each question that is a choice (coverage threshold, external tools, visual review, CI rules) is a decision request: lettered options (A, B, C) under numbered questions (reply 1 A 2 C), each with its pros and cons, the recommended option marked, and why it is recommended (see Decision requests in the metaswarm plugin's guides/delivery-scope.md); a line each is enough, and the option labelled "(Recommended)" is that recommendation. Questions that only collect a fact (the language or stack when detection finds none) are exempt.
Always ask:
Ask only if relevant:
External AI tools — Ask only for non-trivial projects: "Set up external AI tools (Codex/Gemini) for cost savings on implementation?" Options: "Yes" / "No"
Visual review — Ask only if a web framework was detected (Next.js, Nuxt, React, Vue, Angular, SvelteKit, Django, Flask): "Enable visual screenshot review for UI changes?" Options: "Yes" / "No"
CI pipeline — Ask only if NO CI detected. For a stack that 5.4 renders (Node with npm, pip-based Python, Go, Rust): "Create a GitHub Actions CI pipeline?" Options: "Yes (Recommended)" / "No". For any other stack (pnpm, yarn, bun, Poetry, uv, Pipenv, Java, Ruby…), metaswarm can't write the whole workflow, so ask instead: "Add metaswarm's coverage job to a GitHub Actions workflow? I'll show you ci-coverage-job.yml and what to change for your toolchain." Options: "Yes" / "No"
Git hooks — Ask only if NO hooks detected: "Set up git hooks for pre-push quality checks?" Options: "Yes (Recommended)" / "No"
This is the FIRST thing to do after Phase 2. Determine the coverage command, then run:
PLUGIN_ROOT="${PLUGIN_ROOT:-${CLAUDE_PLUGIN_ROOT:-${extensionPath:-}}}"
if [ -z "$PLUGIN_ROOT" ]; then
setup_script="$(find "${CODEX_HOME:-$HOME/.codex}/plugins/cache" -path '*/metaswarm/*/lib/setup-mandatory-files.sh' -print -quit 2>/dev/null)"
if [ -n "$setup_script" ]; then
PLUGIN_ROOT="$(cd "$(dirname "$setup_script")/.." && pwd)"
fi
fi
if [ -z "$PLUGIN_ROOT" ] && [ -f "$(pwd)/lib/setup-mandatory-files.sh" ]; then
PLUGIN_ROOT="$(pwd)"
fi
bash "${PLUGIN_ROOT}/lib/setup-mandatory-files.sh" "$(pwd)" <threshold> "<coverage-command>" --platform <platform> --reconfigure
Example for Codex with Python/pytest at 100%:
bash "${PLUGIN_ROOT}/lib/setup-mandatory-files.sh" "$(pwd)" 100 "pytest --cov --cov-fail-under=100" --platform codex --reconfigure
Check the JSON output. If "status": "ok", the 3 mandatory files are done. Report to the user what was created, and show them every entry in warnings.
If the script fails or is not found, write the files manually (see CRITICAL-REQUIREMENTS above for what they are).
If the instruction file was newly written (not appended), use Edit to replace the TODO placeholders:
npm test / npm run test:coverage with the detected test/coverage commandsTypeScript strict mode / ESLint + Prettier with the detected language tools<!-- TODO: ... --> comment linesIf the instruction file was appended to (existing file), this step is not needed.
Read each file from ./knowledge/:
patterns.jsonl, gotchas.jsonl, decisions.jsonl, api-behaviors.jsonl, codebase-facts.jsonl, anti-patterns.jsonl, facts.jsonlWrite them to .beads/knowledge/ in the project. Skip any that already exist.
Read each file from ./bin/:
estimate-cost.sh, external-tools-verify.sh, pr-comments-check.sh, pr-comments-filter.shWrite them to bin/ in the project. Make executable with chmod +x. Skip any that already exist.
Do NOT copy metaswarm-agents.sh or metaswarm-usage into the project. Skills always run them from the plugin: the plugin bin/ is on PATH in Claude Code, so resolve with command -v metaswarm-agents.sh, falling back to ${CLAUDE_PLUGIN_ROOT:-$PLUGIN_ROOT}/bin/metaswarm-agents.sh.
.claude/agents/ already exists (it matters for Phase 6)..metaswarm/models.yaml is absent, copy ./templates/models.yaml to .metaswarm/models.yaml (create .metaswarm/ if needed).MA="$(command -v metaswarm-agents.sh || echo "${CLAUDE_PLUGIN_ROOT:-$PLUGIN_ROOT}/bin/metaswarm-agents.sh")" # command -v metaswarm-agents.sh
"$MA" generate
This writes .claude/agents/metaswarm-<role>.md. Exit 1 means a file was hand-edited or is user-authored; report it to the user and do not pass --force unless they ask. Exit 2 means models.yaml has a syntax error (models.yaml:<line>: <reason>); show it and ask the user to fix it.
Read each file from ./scripts/:
beads-fetch-pr-comments.ts, beads-fetch-conversation-history.tsWrite them to scripts/ in the project. Skip any that already exist.
Note: The former beads-self-reflect.ts script is no longer bundled. /self-reflect captures session learnings on its own and needs no extra script.
Node.js dependency warning: If Node.js was NOT detected as the project language, print:
"Note: scripts/*.ts require Node.js (npx tsx) to run. Some advanced features (PR comment fetching, conversation history) will work once Node.js is available. Core metaswarm functionality does not require Node.js."
| Condition | Source | Destination |
|---|---|---|
| User chose YES for CI | ./templates/ci.yml, rendered (see 5.4); other stacks get the ci-coverage-job.yml note instead | .github/workflows/ci.yml |
| User chose YES for git hooks AND Husky detected or Node.js project | ./templates/pre-push | .husky/pre-push (chmod +x) |
| User chose YES for external tools | ./templates/external-tools.yaml | .metaswarm/external-tools.yaml |
| Always | ./templates/.env.example | .env.example |
| Always | ./templates/SERVICE-INVENTORY.md | SERVICE-INVENTORY.md |
| Always | ./templates/gitignore | Merge into existing .gitignore (append missing entries, never duplicate) |
For .gitignore, read the existing file (if any), then append language-specific entries that are not already present. Always ensure .env, .DS_Store, and *.log are included.
Write .metaswarm/project-profile.json with all detection results and user choices:
{
"metaswarm_version": "1.0.0",
"distribution": "plugin",
"installed_at": "{current ISO 8601 timestamp}",
"updated_at": "{current ISO 8601 timestamp}",
"detection": {
"language": "{detected language}",
"framework": "{detected framework or null}",
"test_runner": "{detected test runner}",
"linter": "{detected linter or null}",
"formatter": "{detected formatter or null}",
"package_manager": "{detected package manager or null}",
"type_checker": "{detected type checker or null}",
"ci": "{detected CI system or null}",
"git_hooks": "{detected hook system or null}"
},
"choices": {
"coverage_threshold": 100,
"external_tools": false,
"visual_review": false,
"ci_pipeline": false,
"git_hooks": false
},
"commands": {
"test": "{resolved test command}",
"coverage": "{resolved coverage command}",
"lint": "{resolved lint command or null}",
"typecheck": "{resolved typecheck command or null}",
"format_check": "{resolved format check command or null}"
}
}
Fill all values from detection and user answers. Use null for anything not detected.
Command resolution reference:
| Test Runner | Pkg Mgr | Test Command | Coverage Command |
|---|---|---|---|
| vitest | pnpm | pnpm vitest run | pnpm vitest run --coverage |
| vitest | npm | npx vitest run | npx vitest run --coverage |
| vitest | yarn | yarn vitest run | yarn vitest run --coverage |
| jest | pnpm | pnpm jest | pnpm jest --coverage |
| jest | npm | npx jest | npx jest --coverage |
| jest | yarn | yarn jest | yarn jest --coverage |
| mocha | any | npx mocha | npx nyc mocha |
| pytest | -- | pytest | pytest --cov --cov-fail-under={threshold} |
| go test | -- | go test ./... | go run .metaswarm/go-coverage-gate.go |
| cargo test | -- | cargo test | cargo tarpaulin --fail-under {threshold} |
| mvn test | -- | mvn test | mvn test jacoco:report |
| gradle test | -- | gradle test | gradle test jacocoTestReport |
command -v codex, command -v gemini)--version.metaswarm/external-tools.yaml — set enabled: true for installed tools, enabled: false for missing onesnpx playwright install chromium via BashNode.js/TypeScript: Install Husky if not present, run npx husky init, write pre-push hook.
Python: Suggest pip install pre-commit and offer to create .pre-commit-config.yaml.
Other: Suggest appropriate hook tools for the ecosystem.
The Node pre-push hook runs lint and typecheck only when package.json defines them, and a failing one blocks the push.
Run these with the PLUGIN_ROOT resolved in Phase 3 Step 1 (shell variables don't carry between calls, so repeat that resolution block or use the path it found).
Render the workflow for the detected stack. --stack is node (JavaScript/TypeScript installed with npm), python (pip with requirements*.txt or a pyproject.toml package), go or rust. A project on pnpm, yarn or bun, or a Python project managed by Poetry, uv or Pipenv, gets the same treatment as a stack with no toolchain (exit 2 below), because the template's install steps don't fit it:
bash "${PLUGIN_ROOT}/lib/render-ci.sh" --stack <stack> --out .github/workflows/ci.yml
It keeps that stack's toolchain steps, and points push at the repo's default branch (from origin/HEAD, else gh repo view). Pull requests into any branch are checked. Node's lint and typecheck steps skip a script that package.json doesn't define, and fail the build when one fails. If it prints a warning that it guessed main for the branch, tell the user and re-run with --branch <name> if their default branch differs. Exit 1 means it couldn't render, for example because the branch name has characters a workflow file can't hold. Show the user its message, and run it again with --branch <name> once they give a branch to use. Exit 2 means the stack has no toolchain in the template (Java, Ruby, and so on). Don't write ci.yml then. Show the user the coverage-simple job from ./templates/ci-coverage-job.yml to add to their workflow. Its install step already handles pnpm, yarn and bun from the lockfile; for any other stack, tell them to replace that step with their toolchain's setup and install steps (the file's header has Poetry, uv, Pipenv and Java examples). A project that is both JavaScript and Python keeps the step and adds its Python steps after it.
Do this step and the next only if step 1 wrote .github/workflows/ci.yml (exit 0). With no ci.yml, the CI checks job never runs, so requiring it would block every PR. In that case, add a tip to the summary instead: once the user's own CI runs the coverage job, require that job's check (its name:, Coverage Enforcement in ci-coverage-job.yml).
CI only stops a merge if its check is required. Use AskUserQuestion: "Make the CI checks job a required check on the default branch, so a PR can't merge while coverage fails? This needs admin rights on the GitHub repo. It adds a ruleset and leaves your existing branch protection as it is. The check also applies to direct pushes to that branch, so changes land through PRs." Options: "Yes (Recommended)" / "No, I'll do it later"
Only on Yes, run:
bash "${PLUGIN_ROOT}/lib/require-ci-check.sh"
It adds a ruleset named metaswarm: required CI check and does nothing if that ruleset already exists. Once it succeeds, the default branch takes no direct pushes, so tell the user to land the setup files through a PR: commit them on a branch and open one, which is also the first run of the new check. If it exits 1 (no gh, not logged in, or no admin rights), show the user the manual steps it printed. A private repo on GitHub Free can't use rulesets or branch protection at all; say so if GitHub's error mentions the plan. On No, put those steps in the summary tips: Settings → Rules → Rulesets, target the default branch, and require the status check CI checks.
Present a final summary:
Setup complete! Here's what was configured:
Project: {name}
Language: {language}
Framework: {framework or "None"}
Test runner: {test_runner} -> `{test command}`
Coverage: {threshold}% -> `{coverage command}`
Linter: {linter or "None"}
Formatter: {formatter or "None"}
CI: {ci or "None"}
Git hooks: {hooks or "None"}
External tools: {Enabled/Disabled}
Visual review: {Enabled/Disabled}
Mandatory files:
✔ {instruction file} — {written new / appended metaswarm section / already had it}
✔ .coverage-thresholds.json — {threshold}% coverage, enforcement: `{command}`
✔ .claude/commands/ — Claude only: shims for start-task, prime, review-design, self-reflect, pr-shepherd, brainstorm
Other files written:
{list every other file written or modified with its path}
You're all set! Run the platform's start command to begin working.
Restart note: if .claude/agents/ did not exist before Phase 3 and generate created it, tell the user to restart the session (Claude Code only watches agent directories that existed at session start). Until then the plugin's default phase models apply.
Command naming: When recommending metaswarm skills to the user, use $name forms ($start, $setup, $status, $pr-shepherd) unless the active platform has already created and selected its own command shims.
Offer 1-2 relevant tips based on configuration:
$external-tools to check tool status."/setup, or render the template yourself with lib/render-ci.sh --stack <stack> from the metaswarm plugin."CI checks status check on your default branch (Settings → Rules → Rulesets) so a failing PR can't merge."If $start is invoked and .metaswarm/project-profile.json does not exist, the start skill should auto-route here. This skill will run the full setup flow, then hand back to $start to continue with the user's original request.
Before saying "setup complete", run this Bash command to verify the 3 mandatory files:
platform="${METASWARM_PLATFORM:-${CLAUDE_PLUGIN_ROOT:+claude}}"
platform="${platform:-${extensionPath:+gemini}}"
platform="${platform:-${CODEX_HOME:+codex}}"
platform="${platform:-${PLUGIN_ROOT:+codex}}"
platform="${platform:-claude}"
case "$platform" in
claude) instruction_file="CLAUDE.md" ;;
gemini) instruction_file="GEMINI.md" ;;
codex) instruction_file="AGENTS.md" ;;
*) echo "UNKNOWN PLATFORM: $platform"; exit 1 ;;
esac
echo "$instruction_file:"; grep -c "metaswarm" "$instruction_file" 2>/dev/null || echo "MISSING"
echo "coverage:"; ls .coverage-thresholds.json 2>/dev/null || echo "MISSING"
if [ "$platform" = "claude" ]; then
echo "shims:"; ls .claude/commands/start-task.md .claude/commands/prime.md .claude/commands/brainstorm.md 2>/dev/null || echo "MISSING"
fi
If any output says "MISSING", go back and run the setup-mandatory-files.sh script or create the files manually. Do NOT declare success with missing files.
When reporting available commands to the user, use $name skill invocation unless the active platform has its own confirmed command shims. Do NOT recommend commands that do not exist on that platform.
bin/estimate-cost.sh (opens in a new tab)bin/external-tools-verify.sh (opens in a new tab)bin/metaswarm-agents.sh (opens in a new tab)bin/metaswarm-usage (opens in a new tab)bin/pr-comments-check.sh (opens in a new tab)bin/pr-comments-filter.sh (opens in a new tab)knowledge/README.md (opens in a new tab)knowledge/anti-patterns.jsonl (opens in a new tab)knowledge/api-behaviors.jsonl (opens in a new tab)knowledge/codebase-facts.jsonl (opens in a new tab)knowledge/decisions.jsonl (opens in a new tab)knowledge/facts.jsonl (opens in a new tab)knowledge/gotchas.jsonl (opens in a new tab)knowledge/patterns.jsonl (opens in a new tab)scripts/beads-fetch-conversation-history.ts (opens in a new tab)scripts/beads-fetch-pr-comments.ts (opens in a new tab)templates/AGENTS-append.md (opens in a new tab)templates/AGENTS.md (opens in a new tab)templates/CLAUDE-append.md (opens in a new tab)templates/CLAUDE.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
metaswarm@metaswarm-marketplace is listed by dsifry/metaswarm-marketplace — review the source before installing
npx claudepluginhub dsifry/metaswarm-marketplace --plugin metaswarm15 skills in this plugin
/brainstorming-extensionLoads the assumption ledger and misreadings checklist at the start of brainstorming, and enforces the design review gate when a project-sized design doc is committed — bridges superpowers:brainstorming into the metaswarm quality pipeline/create-issueCreate comprehensive GitHub issues with TDD plans, acceptance criteria, and agent instructions for autonomous PR lifecycle management/design-review-gateAutomatic review gate that runs when brainstorming commits a project-sized design doc - spawns PM, Architect, Designer, Security, UX Reviewer and CTO agents in parallel, iterates under the severity rule until all approve or it escalates/external-toolsDelegate implementation and review tasks to external AI CLI tools (Codex, Gemini) with cross-model adversarial review/handling-pr-commentsAddress PR review feedback systematically — fetch inline comments, review bodies, handle outside-diff-range comments, resolve threads with proper attribution/handoffAnalyze the current session and write a self-contained handoff document so a fresh agent can resume the work with full context — outputs a single "Read XXX.md and do YYY." sentenceOther plugins' skills for the same job