From coral
Initializes new or existing projects for AI-assisted development: scans project structure, identifies domain, generates skill artifacts, and runs a review loop via sub-agents.
How this skill is triggered — by the user, by Claude, or both
Slash command
/coral:init-project [existing|new][existing|new]The summary Claude sees in its skill listing — used to decide when to auto-load this skill
<Role>
references/backend.mdreferences/data.mdreferences/frontend.mdreferences/gpu.mdreferences/infra.mdreferences/merge-policy.mdreferences/ml-ai.mdreferences/mobile.mdreferences/plugin-extension.mdreferences/systems.mdreferences/writing-guide.mdtemplates/CLAUDE.md.templatetemplates/agents/AGENT.md.templatetemplates/agents/code-critic.mdtemplates/agents/doc-critic.mdtemplates/agents/test-critic.mdtemplates/agents/ux-critic.mdtemplates/rules/agents.md.templatetemplates/rules/conventions.md.templatetemplates/rules/design-philosophy.md.templateResponsible 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 before writing agents; one agent per concern; justify omissions.
In the Tier-2 fallback, first produce an explicit concern → severity → agent table for the
domain. Give each distinct failure mode its own agent — do not bundle several into one
guardian — and record in agents.md why any plausible agent was deliberately NOT created
(covered-by-X), 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. 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: generate the union of all relevant agents. Each domain gets its own validation rules.
Tier 2 fallback (no Tier 1 match): Identify what a senior engineer would always check in review. Create agents by severity: data loss/security → tier 1 (opus), bugs → tier 2 (sonnet), code quality → tier 3 (sonnet).
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: required agents, mandatory concerns, validation items, core patterns, recommended docs.
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 patternspaths: 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 create the coral project data symlink and add it to .gitignore:
# Symlink .claude/coral → ~/.coral/projects/{slug}/
if [ ! -e .claude/coral ] && [ ! -L .claude/coral ]; then
mkdir -p "CORAL_PROJECT"
ln -s "CORAL_PROJECT" .claude/coral
fi
# Add to .gitignore if not already present
grep -qxF '.claude/coral' .gitignore 2>/dev/null || echo '.claude/coral' >> .gitignore
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}
### 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 | - |
| Rules | .claude/rules/design-philosophy.md | Must exist | - |
| Rules | .claude/rules/validation.md | Must exist | - |
| Rules | .claude/rules/conventions.md | Must exist | - |
| 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 |
| 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> |
npx claudepluginhub kangig94/coral --plugin coralScaffolds a new project with directory structure, CLAUDE.md, config files, hooks, skills, and first commit after interviewing the developer for name, description, stack, and optional components.
Scaffolds greenfield project architecture and AI agent harness via interview-driven decisions. Outputs markdown spec with code structure exemplar, tests, guardrails, CLAUDE.md setup, and unified plan. Invoke via /scaffold for new projects.
Auto-generates CLAUDE.md and .rune/ context for AI sessions by scanning codebase structure, config files, and tech stack. Saves re-explaining project context on undocumented repos.