Main entry point for CCAutomated. Analyzes a target repository and generates or updates the Claude Code configuration (agents, skills, rules, hooks, settings, CLAUDE.md, .mcp.json) tailored to that repo. Detects existing setups and presents strategy options (Update / Merge / Replace) before touching anything.
You have been invoked with /generate-setup. Your job is to generate or update a complete Claude Code setup for the target repository.
$ARGUMENTS
Spawn the Code Researcher to build a Target Profile. The profile MUST include a detailed Existing Setup Analysis section if any Claude Code config is detected (.claude/, CLAUDE.md, .mcp.json).
Spawn in parallel:
If the Code Researcher reports an existing setup, present the user with:
| Strategy | Behavior | When to use |
|---|---|---|
| Update (default) | Only touch files affected by detected changes — new deps, new dirs, stack drift. Preserve everything else untouched. | Setup exists and mostly works, repo just evolved |
| Merge | Generate the full ideal setup, then merge with existing — keep user customizations, add missing pieces, update stale parts. | Setup exists but is outdated or incomplete |
| Replace | Full regeneration. Back up existing to pre-ccautomated branch, then overwrite. | Setup is broken or user wants a clean slate |
If no existing setup is detected, skip this step and proceed with full generation.
Synthesize all research into a generation plan. The plan MUST include a per-file disposition table showing what happens to each file:
| File | Exists? | Action | Rationale |
|------|---------|--------|-----------|
| CLAUDE.md | Yes (42 lines) | MERGE — append stack rules, keep existing | Has user-written context |
| settings.json | Yes | UPDATE — add missing hooks | Permissions look current |
| agents/researcher.md | Yes | KEEP — no changes | Already tailored |
| agents/mutagen.md | No | CREATE | Missing from setup |
| rules/tests.md | Yes | REPLACE — outdated | References old framework |
| .mcp.json | Yes | MERGE — add context7 | Has existing servers |
Valid per-file actions:
Present the plan to the user for approval.
Spawn the Implementer with:
Spawn the Reviewer. If changes requested, iterate (max 3 cycles).
Spawn Mutagen to log the generation in .claude/mutagen-memory/version-history.md and collect user feedback.
For the target repo (subject to per-file actions above):
CLAUDE.md — Project instructions tailored to the repo's stack.claude/hooks/post-tool-use.sh — Mutagen real-time usage logger (from template, made executable).claude/hooks/stop-session-metrics.sh — Mutagen session metrics aggregator (from template, made executable).claude/settings.json — Permissions, hooks referencing the scripts above, model config.claude/agents/ — Agents tailored to the repo (including Mutagen + Mutagen Discovery).claude/skills/ — Stack-relevant skills.claude/rules/ — Path-specific rules for the repo's structure.mcp.json — MCP servers relevant to the detected stack.gitignore additions — Ensure .claude/, CLAUDE.md, .mcp.json are gitignoredmodel: opus