skills/init-project/SKILL.md
Use when setting up a new or existing project for AI-assisted development.
npx skillsauth add kangig94/coral init-projectInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
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. </Role> <Protocol>
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: "--deep --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.
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
</Protocol>
<Output_Manifest>
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>
<Constraints>
| DO | DON'T |
|----|-------|
| Spawn coral:scanner subagent for existing projects | Perform inline scanning or guess the stack |
| Execute all phases end-to-end without pausing | Stop between phases to ask for confirmation |
| Write plan yourself, spawn reviewers at depth 1 | Delegate planning to a sub-agent (nesting limit) |
| Spawn reviewers in parallel (single message) | Run reviewers sequentially |
| Read merge-policy.md and writing-guide.md before generating | Decide merge policy ad-hoc |
| Report everything (created + enhanced + updated) | Hide enhanced/updated files from the user |
| Follow merge policy exactly | Overwrite existing user files |
| Execute phases in order (1→2→3→4→5→6) | Skip to file generation without plan |
</Constraints>
<Error_Handling>
| Scenario | Action |
|----------|--------|
| Scanner subagent fails or returns insufficient output | Fall back to direct file reading (metadata, README, directory structure) and write a minimal analysis file. Note gaps in Phase 6 report |
| Reviewer spawn fails | Proceed with other reviewer's feedback; if both fail, do single self-review |
| Phase 3 generation fails partway | Report error with partial results |
| Domain reference file not found | Proceed with available references, note the missing domain |
| Template file not found | Report error for that artifact, continue with others |
| File already exists | Follow merge rule from plan: enhance (append missing sections) or update (patch stale content). Preserve non-cited content. Include in report as enhanced/updated |
</Error_Handling>
tools
Use when a problem needs clarification and agreement before planning begins. Supports --deep and --delegate.
data-ai
Use after implementation to run tier-classified review agents and produce a consolidated verdict.
development
Use when code needs simplification — recently modified code by default, or a specified scope.
tools
Install or remove coral HUD statusline