/coral:init-project [existing|new]from coral
Sets up new or existing projects for AI-assisted development by analyzing the project, identifying domains, writing plans, running review loops, and generating artifacts.
Ships in coral. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Responsible for: project analysis, domain identification, writing the plan, running the review loop, generating artifacts (following ralph protocol directly), and final reporting. Not responsible for: reviewing the plan (architect/critic do that).
Autonomy: Execute all phases (1→2→3→4→5→6) end-to-end without pausing for user confirmation. Evidence gates are self-checks, not user approval points. Do not ask "shall I continue?" between phases. <Execution_Discipline> Work conventions that guard failure modes which recur in this protocol. They bind across all phases — treat each as a precondition, not advice. Governing principle: setup work is verified to the same bar as feature code — confirm against the authoritative source (the templates), never declare "sufficient" from memory or a partial scan.
Full-tree discovery before any "missing" conclusion. Never decide a template or
reference is absent from a depth-limited or filtered listing. Run
find {skill_base_dir}/templates -type f (no -maxdepth, no grep pre-filter) once and
treat that inventory as authoritative. The "template not found" fallback may fire only
after a full listing confirms absence.
Fixed artifacts are copied, never authored from memory. Every artifact the protocol
calls fixed — templates/skills/tier-review/SKILL.md, templates/agents/{code,doc,test,ux}-critic.md —
is produced by: read the template file → copy it → graft only project-specific hooks. Do
not reconstruct it from another repo's output or recollection; you will drop required sections.
Read every template in full; obey directives in its body. Templates contain
instructions, not only {placeholders} (e.g. tier-review's "add coral:architect to the list
with tier 1 by default"). Read the whole file before instantiating and treat its imperative
sentences as requirements.
Diff-against-template is part of Phase 4. Verification asserts each generated fixed artifact contains every section and directive its template has — a structural diff, not a frontmatter-key existence check. "name: present" does not catch a dropped section.
Enumerate concerns first, then group them into the fewest agents that keep each one sharp.
Every agent is a separate spawn that re-reads the diff and its context on every review, so an
agent that could have been merged is a cost the user pays forever. Before writing any agent,
produce one concern table for the whole project (all domains together):
concern → severity → invariant → trigger (which diffs invoke it) → already proven by a gate?
Then form the roster from it:
Beyond three domain agents (fixed critics not counted), each additional one needs a written
reason it cannot merge — its trigger or invariant differs from every other agent's. Record
every merge and exclusion in agents.md ## Excluded Agents (covered-by-X, or proven-by-gate),
so the roster is a justified decision, not an accident.
Tier discipline is explicit. Tier-1/2 safety guardians are binary gates
(PASS / NEEDS WORK on BLOCKING findings, no rubric); Tier-3 quality agents are rubric-scored.
Documentation reviewers are the separate doc tier — rubric-scored like Tier 3, and run last,
after the code fixes, under tier-review --gated. Never put a documentation reviewer in tiers 1–3.
A guardian without a score and a critic with one are both correct — do not "fix" either
toward the other.
</Execution_Discipline>
Check the working directory for source files:
Existing project indicators (any of these):
package.json, pyproject.toml, Cargo.toml, go.mod, pom.xml, build.gradlesrc/, lib/, app/, csrc/, cmd/Makefile, CMakeLists.txt, DockerfileREADME.md with project descriptionNew project: Working directory is empty or has only basic scaffolding (e.g., .git/ only).
If ambiguous, treat as existing (safer).
Parse the command argument for:
| Field | Examples |
|---|---|
| Project description | "a CLI tool for...", "REST API that..." |
| Tech stack | "React + FastAPI", "Rust", "Next.js" |
| Architectural concerns | "must be serverless", "multi-tenant" |
| Reference material | "ref/codes", "github.com/...", "docs/spec.md" |
Existing projects: Only ask for reference material if not provided. New projects: Ask only for unknown fields.
If reference material provided, scan before project analysis:
Spawn a scanner subagent to protect the main context window from heavy file I/O.
Create analysis file: Write CORAL_PROJECT/analysis/{YYYY-MM-DD}-init-{project-name}.md:
# Analysis: init-{project-name}
Date: {YYYY-MM-DD}
Question: Scan project structure, architecture, dependencies. Assess documentation quality.
Spawn scanner:
Agent({ subagent_type: "coral:scanner",
prompt: "Scan this project for init-project setup.
Scope: project structure, architecture, dependencies, build/test config.
Also assess documentation quality — gaps, enhancements needed, shallow sections
(file lists without layer diagrams, commands without runnable examples,
any section under 3 lines on non-trivial topics), stale path references.
Focus on: source tree vs .claude/rules, agent definitions vs codebase modules,
CLAUDE.md accuracy, docs/ freshness, new modules/patterns not captured in rules.
{include summary of 1b/1c context if available}
Output a structured scan report." })
Write findings: Append the scanner's output to the analysis file under ## Scan Report.
Add a ## Documentation Assessment section summarizing doc gaps and stale content.
Read the completed analysis file to extract:
For existing projects: read tech stack from the analysis document (1d). For new projects: use argument context (1b) and reference material (1c). Match the identified stack against domains:
| Signal | Domain Reference |
|---|---|
| React, react-dom, Next.js, Vue, Svelte, Angular | references/frontend.md |
| Express, FastAPI, Django, Gin, Actix, Spring | references/backend.md |
| React Native, Flutter, SwiftUI, Jetpack Compose | references/mobile.md |
| obsidian, vscode, chrome extension, claude plugin | references/plugin-extension.md |
| Docker, Kubernetes, Terraform, GitHub Actions | references/infra.md |
| Spark, dbt, Airflow, ETL | references/data.md |
| PyTorch, TensorFlow, transformers, LLM, langchain | references/ml-ai.md |
| C/C++ (no GPU), CMake, RTOS, embedded | references/systems.md |
| CUDA, OptiX, Vulkan, Metal, GPU compute | references/gpu.md |
Multi-domain: take the union of all relevant concerns, not agents, and group them per Execution_Discipline #5 — a concern two domains share is one agent. Each domain gets its own validation rules.
Tier 2 fallback (no Tier 1 match): Identify what a senior engineer would always check in review, as concerns in the #5 table. Group them into agents, and tier each agent by its most severe concern: data loss/security → tier 1 (opus), bugs → tier 2 (sonnet), code quality → tier 3 (sonnet). Documentation review → the doc tier (sonnet), whatever the severity.
references/{domain}.md for each detected domainreferences/writing-guide.mdreferences/merge-policy.mdtemplates/CLAUDE.md.template, templates/rules/*.md.template, templates/agents/*.md (fixed agents), templates/agents/AGENT.md.template (agent writing guide — internal use only, not copied to project), templates/skills/tier-review/SKILL.mdExtract from each domain reference: mandatory concerns, validation items, core patterns, recommended docs, and its agent tables as candidates — they list concerns worth covering, not a roster to copy. Feed them into the #5 concern table and let its grouping decide the agents.
Invoke the planning protocol via Skill expansion (inline, not a subagent — depth does not increase). You remain at depth 0 and can still spawn reviewers at depth 1.
Skill({ skill: "coral:plan", args: "round=1 --no-handoff init-{project-name}" }).
init-{project-name}module | responsibility rows,
not per-file sections with export catalogs. See writing-guide Module Doc Requirements.Evidence gate: Phase 2 is complete ONLY when a plan file exists at CORAL_PROJECT/plans/init-*.md.
If no file exists on disk, Phase 2 did not execute correctly.
Precondition: Plan file from Phase 2 must exist on disk. Verify with Glob before proceeding. If plan file does not exist, STOP and report: "Phase 2 did not produce a plan file. Cannot proceed to Phase 3." Do NOT attempt to write a plan or execute without one.
.claude/rules/ is auto-loaded by Claude Code. Writing files there incrementally exposes
partial state. Stage all .claude/ files in a temp directory, then move atomically.
Staging directory: CORAL_PROJECT/init-staging/
Already outside the project tree (~/.coral/projects/{slug}/), no platform-specific temp dir needed.
STAGING="CORAL_PROJECT/init-staging"
rm -rf "$STAGING" && mkdir -p "$STAGING"
Write rules:
.claude/ files (new, enhanced, and updated): Write to $STAGING/dot-claude/.... For enhanced/updated files, first cp the existing file into staging, then Edit there.CORAL_PROJECT/ working files (plans, analysis): Write directly (not auto-loaded)docs/ files (new, enhanced, and updated): Write directly (not auto-loaded)Invoke Skill({ skill: "coral:ralph", args: "execute the plan from Phase 2. Stage all .claude/ files (new, enhanced, and updated) under $STAGING/dot-claude/ instead of .claude/ directly. For enhanced/updated files, cp the original into staging first, then Edit there." }).
Same pattern as Phase 2 — you execute at depth 0, spawning subagents at depth 1 as needed.
You MUST read these reference files before generating any artifacts:
{skill_base_dir}/references/merge-policy.md — per-artifact merge rules (skip/create/enhance/update){skill_base_dir}/references/writing-guide.md — artifact quality standardsUse {skill_base_dir}/templates/ and {skill_base_dir}/references/ for template and reference lookups.
{skill_base_dir} is the absolute plugin path — do NOT use relative paths.
The analysis file (from Phase 1d) provides factual grounding, not content drafts.
Doc content comes from the plan — write what the plan specifies, not from your own analysis.
Also write $STAGING/dot-claude/skills/tier-review/SKILL.md by copying from
{skill_base_dir}/templates/skills/tier-review/SKILL.md — fixed artifact, not plan-dependent.
Evidence gate: Phase 3 is complete ONLY when all artifacts exist in staging ($STAGING/dot-claude/)
and directly-written locations (docs/). Do NOT move staged files yet — verification comes first.
Verify BEFORE moving to final locations. .claude/rules/ is auto-loaded — placing
unverified files there exposes partial or incorrect state to Claude Code.
Agent("coral:architect") and Agent("coral:critic") in parallel to verify generated artifacts. Pass --deep in the prompt.
Include in each spawn prompt: "Review is read-only. NEVER run git checkout, git switch, git stash,
git reset, git restore, or git clean, and never stage or commit — you share this working tree
with parallel reviewers and staged Phase 3 artifacts. To inspect another revision, use git diff <ref>,
git show <ref>:<path>, or git log <ref> — never check it out."
Provide each with: plan file path, list of generated/enhanced/updated files from Phase 3.
For .claude/ files, point reviewers to the staging paths ($STAGING/dot-claude/...).
For docs/ files, point to their actual paths (written directly in Phase 3b).
Each outputs a findings table with severity (CRITICAL/HIGH/MEDIUM/LOW) and file:line references.
Architect — structural correctness and content fidelity:
{skill_base_dir}/references/writing-guide.md for structural standards<Agent_Prompt> XML with required sections, no {placeholder} text, protocols reference real project patterns## Excluded Agents records every
merge and exclusionpaths: frontmatter for domain-specific, validation items trace to analysis findingsCritic — plan adherence and completeness:
Remediation: Synthesize both reports. For CRITICAL/HIGH findings, fix directly (read → edit).
Fix .claude/ files in staging, docs/ files in place.
Evidence gate: Phase 4 is complete when neither reviewer has unresolved CRITICAL/HIGH findings.
Only after Phase 4 passes, move staged files to their final location:
cp -r "$STAGING/dot-claude/"* .claude/ && rm -rf "$STAGING"
Then run Coral's shared project-ignore maintainer. It preflights the complete change,
writes the anchored .git/info/exclude entry, creates or reuses the symlink, and then
retracts Coral-owned scoped and Git-root lines. This is the same bounded, atomic
implementation used by SessionStart; do not reimplement these mutations with shell
text processing. The maintainer writes its result JSON alone to stdout and writes every
distinct refusal remedy to stderr, so command substitution preserves parseable result
data while the operator still sees each named exit.
CORAL_PROJECT_IGNORE_SCRIPT="{skill_base_dir}/../../hooks/project-ignore.mjs"
CORAL_PROJECT_IGNORE_OWNER="{skill_base_dir}/../../hooks/project-ignore-owner.mjs"
CORAL_PROJECT_IGNORE_STATUS=0
CORAL_PROJECT_IGNORE_RESULT="$(
node "$CORAL_PROJECT_IGNORE_OWNER" --project-dir "$PWD" --create-symlink
)" || CORAL_PROJECT_IGNORE_STATUS=$?
if [ "$CORAL_PROJECT_IGNORE_STATUS" -eq 75 ]; then
echo "CORAL_PROJECT_IGNORE_OUTCOME=maintenance-busy" >&2
echo "Another Coral project-ignore maintainer owns the lock. Wait for it to finish, or terminate it if it is stuck, then retry." >&2
exit 1
fi
if [ "$CORAL_PROJECT_IGNORE_STATUS" -eq 69 ] || [ "$CORAL_PROJECT_IGNORE_STATUS" -eq 126 ] || [ "$CORAL_PROJECT_IGNORE_STATUS" -eq 127 ]; then
echo "CORAL_PROJECT_IGNORE_OUTCOME=maintenance-lock-unavailable" >&2
echo "Coral project-ignore setup could not open the maintenance lock or launch its owner. Ensure ~/.coral/staging is writable and flock is executable, then retry." >&2
exit 1
fi
if [ "$CORAL_PROJECT_IGNORE_STATUS" -ne 0 ] && [ -z "$CORAL_PROJECT_IGNORE_RESULT" ]; then
echo "CORAL_PROJECT_IGNORE_OUTCOME=no-output" >&2
echo "Coral project-ignore setup exited with status $CORAL_PROJECT_IGNORE_STATUS without reporting a result. Its stderr is shown above; if it emitted no diagnostic, retry this command and report a recurring failure as a Coral defect." >&2
exit 1
fi
if ! printf '%s\n' "$CORAL_PROJECT_IGNORE_RESULT" | node "$CORAL_PROJECT_IGNORE_SCRIPT" --validate-result; then
echo "CORAL_PROJECT_IGNORE_OUTCOME=unparseable-output" >&2
echo "Coral project-ignore setup returned malformed result data. Retry /coral:init-project; if it recurs, report the captured result as a Coral defect." >&2
exit 1
fi
case "$CORAL_PROJECT_IGNORE_RESULT" in
*'"status":"complete"'*) CORAL_PROJECT_IGNORE_RESULT_STATUS=complete; CORAL_PROJECT_IGNORE_EXPECTED_STATUS=0 ;;
*'"status":"partial"'*) CORAL_PROJECT_IGNORE_RESULT_STATUS=partial; CORAL_PROJECT_IGNORE_EXPECTED_STATUS=1 ;;
*'"status":"refused"'*) CORAL_PROJECT_IGNORE_RESULT_STATUS=refused; CORAL_PROJECT_IGNORE_EXPECTED_STATUS=1 ;;
*)
echo "CORAL_PROJECT_IGNORE_OUTCOME=unparseable-output" >&2
echo "Coral project-ignore setup returned an unreadable result. Inspect the reported JSON and retry." >&2
exit 1
;;
esac
if [ "$CORAL_PROJECT_IGNORE_STATUS" -ne "$CORAL_PROJECT_IGNORE_EXPECTED_STATUS" ]; then
echo "CORAL_PROJECT_IGNORE_OUTCOME=unparseable-output" >&2
echo "Coral project-ignore setup returned a result inconsistent with its process status. Retry /coral:init-project; if it recurs, report both values as a Coral defect." >&2
exit 1
fi
printf 'CORAL_PROJECT_IGNORE_RESULT=%s\n' "$CORAL_PROJECT_IGNORE_RESULT" >&2
if [ "$CORAL_PROJECT_IGNORE_RESULT_STATUS" = partial ]; then
echo "CORAL_PROJECT_IGNORE_OUTCOME=partial" >&2
echo "Coral project-ignore setup reported a partial result. Inspect CORAL_PROJECT_IGNORE_RESULT, apply the remedy printed above, then rerun /coral:init-project." >&2
exit 1
fi
if [ "$CORAL_PROJECT_IGNORE_RESULT_STATUS" = refused ]; then
echo "CORAL_PROJECT_IGNORE_OUTCOME=refused" >&2
echo "Coral project-ignore setup refused before making progress. Inspect CORAL_PROJECT_IGNORE_RESULT, apply the remedy printed above, then rerun /coral:init-project." >&2
exit 1
fi
if [ "$CORAL_PROJECT_IGNORE_STATUS" -ne 0 ]; then
echo "Coral project-ignore setup reported complete with an inconsistent process exit. Inspect CORAL_PROJECT_IGNORE_RESULT and retry." >&2
exit 1
fi
Keep CORAL_PROJECT_IGNORE_RESULT for the Phase 6 report. A successful result
confirms that .git/info/exclude carries Coral's anchored project-relative symlink
entry and that the Coral-owned standalone coral line was retracted from
.claude/.gitignore. Coral no longer owns or adds any scoped ignore line, including
*.coral-*.tmp; the manifest verifies their absence. A partial result records changes
that already happened; report them from the artifact dispositions instead of
describing the run as refused.
Summarize:
## Init Complete
### Generated
- {list of created files with brief descriptions}
### Enhanced (existing files)
- {files that were enhanced with new sections}
### Updated (stale content corrected)
- {files with targeted edits, what was changed and why}
- {report the project-ignore migration result by status and artifact disposition:
anchored `.git/info/exclude` entry, removed Coral-owned scoped and Git-root lines
when present, and created/reused `.claude/coral`}
### Note
{If CLAUDE.md was enhanced/updated: mention what was added/changed vs preserved}
### Next Steps
- Review generated rules in .claude/rules/ - customize for your project
- Review .claude/CLAUDE.md - adjust project description and build commands
- Invoke `Skill(tier-review)` after your first implementation to test the setup
After Phase 5 (Apply) completes, confirm these files exist with correct content. Missing files or failed content checks indicate protocol failure.
| Category | File | Condition | Content Check |
|---|---|---|---|
| Analysis | CORAL_PROJECT/analysis/*-init-*.md | If existing project | Scan Report section present |
| Hub | .claude/CLAUDE.md | Must exist (created or pre-existing) | Quality principle line present |
| Rules | .claude/rules/agents.md | Must exist | ## Excluded Agents section present |
| Rules | .claude/rules/design-philosophy.md | Must exist | - |
| Rules | .claude/rules/validation.md | Must exist | - |
| Rules | .claude/rules/conventions.md | Must exist | ## Comments section present |
| Rules | .claude/rules/{domain-specific}.md | At least 1 per detected domain | paths: frontmatter, no {placeholder} text |
| Agents | .claude/agents/code-critic.md | Must exist | Rubric anchors (10/7/4/1) |
| Agents | .claude/agents/doc-critic.md | Must exist | Rubric anchors (10/7/4/1) |
| Agents | .claude/agents/test-critic.md | Must exist | Rubric anchors (10/7/4/1) |
| Template | .claude/templates/AGENT.md | Must NOT be created | Internal template — not deployed to user project |
| Skills | .claude/skills/tier-review/SKILL.md | Must exist | name: tier-review in frontmatter |
| Ignore | .git/info/exclude | For a Git repository | Anchored, literal-escaped project-relative .claude/coral entry |
| Ignore | .claude/.gitignore | If it exists | Coral-owned standalone coral and *.coral-*.tmp lines absent; every other byte preserved |
| Ignore | Git-root .gitignore | If it contained Coral's legacy project entry | Exact legacy entry absent; every other byte preserved |
| Link | .claude/coral | Must exist as a symlink | Resolves to CORAL_PROJECT |
| Agents | .claude/agents/{domain-specific}.md | Per plan | <Agent_Prompt> XML structure |
| Docs | docs/ARCHITECTURE.md | If generated | Layer diagram present |
| Docs | docs/DEV_GUIDE.md | If generated | Exact build/test commands |
| Docs | docs/{domain-specific}.md | Per domain reference Recommended Docs | Architecture-level content, not catalogs |
| If any required file is missing or fails its content check, report it as an error. | |||
| </Output_Manifest> |
references/backend.md (opens in a new tab)references/data.md (opens in a new tab)references/frontend.md (opens in a new tab)references/gpu.md (opens in a new tab)references/infra.md (opens in a new tab)references/merge-policy.md (opens in a new tab)references/ml-ai.md (opens in a new tab)references/mobile.md (opens in a new tab)references/plugin-extension.md (opens in a new tab)references/systems.md (opens in a new tab)references/writing-guide.md (opens in a new tab)templates/CLAUDE.md.template (opens in a new tab)templates/agents/AGENT.md.template (opens in a new tab)templates/agents/code-critic.md (opens in a new tab)templates/agents/doc-critic.md (opens in a new tab)templates/agents/test-critic.md (opens in a new tab)templates/agents/ux-critic.md (opens in a new tab)templates/rules/agents.md.template (opens in a new tab)templates/rules/conventions.md.template (opens in a new tab)templates/rules/design-philosophy.md.template (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
12 skills in this plugin
/code-simplifyUse when code needs simplification — recently modified code by default, or a specified scope.npx claudepluginhub kangig94/coral --plugin coralOther plugins' skills for the same job