skills/init-project/SKILL.md
# Init Project Unified project initialization hub with subcommand routing. Detects, scaffolds, documents, and refines an OpenCode Hubs project. Works for both first-time setup and iterative re-runs. ## When to Use - First time setting up Hubs in a project - Adding Hubs to an existing codebase - Refreshing config after major changes (refactors, new deps, team growth) - Re-running to capture new context and refine docs - Replacing `/hubs-setup`, `/deepinit`, or `/init-project-config` ## No-Arg
npx skillsauth add Thomashighbaugh/opencode skills/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.
Unified project initialization hub with subcommand routing. Detects, scaffolds, documents, and refines an OpenCode Hubs project. Works for both first-time setup and iterative re-runs.
/hubs-setup, /deepinit, or /init-project-configWhen invoked without arguments (/init-project), list the subcommands as plain text and ask the user to choose. Do NOT call hubMenu or any other tool — just output the list directly. Available subcommands: setup, detect, recommend, docs, context, verify, refresh, status, map-codebase, doctor, reset, provision, tag, find-skills, find-agents, find-tools, find-rules.
Directly invoke the matching subcommand. Print the reminder, then delegate to the appropriate phase or agent.
| Subcommand | Phases | Skill/Delegate | What It Does |
|------------|--------|----------------|--------------|
| setup | 0-8 | self (all phases) | Full project initialization — default runs 0-5+8, --full adds 6-7 |
| detect | 0-1 | stack-detector agent | Deep stack detection — languages, frameworks, build tools, testing, ORM, CSS, CI/CD, infra |
| recommend | 2 | stack-recommender skill | Map stack fingerprint to recommended global resources (skills, agents, rules, archetype) |
| docs | 5 | deepinit skill | Regenerate hierarchical AGENTS.md documentation |
| context | 6 | @architect + @convention-extractor + @explore | Deep codebase mapping, context synthesis, agent upgrade (same as setup --full Phase 6) |
| verify | 8 | verifier agent | Validate configuration completeness and integrity, including .gitignore privacy protections |
| refresh | 0-8 (merge) | self (all phases, merge mode) | Update existing config — default runs 0-5+8 merge, --full adds 6-7 (deep re-mapping + integration) |
| status | — | self (inline) | List state files and show checkpoint progress |
| map-codebase | — | inline | Analyze existing codebase — spawn parallel agents to map stack, architecture, conventions (subset of Phase 6) |
| doctor | — | inline | Run diagnostic health check — validate Hubs installation, config integrity, state consistency |
| reset | — | inline | Reset project state — archive .opencode/state and .opencode/context, start fresh |
| provision | 4 | provision skill | Auto-generate .opencode/ agents, skills, tools, rules from stack fingerprint + recommendations |
| tag | — | tag-resources skill | Audit and fix resource tags on global skills, agents, rules, and archetypes |
| find-skills | — | find-skills skill | Search skill registries for relevant per-repo skills |
| find-agents | — | find-agents skill | Search agent registries for relevant per-repo agents |
| find-tools | — | find-tools skill | Search registries and local template catalog for relevant TypeScript tools |
| find-rules | — | find-rules skill | Search registries and local template catalog for relevant OpenCode rules |
Each subcommand follows the hub pattern:
.opencode/state/init/| Subcommand | Reminder on Invoke |
|------------|-------------------|
| setup | Full init from scratch. I'll verify global Hubs, detect your stack, scaffold config, provision agents/tools, generate docs, and validate. Use --full for deep codebase mapping and context capture. |
| detect | Deep stack detection via @stack-detector. I'll analyze languages, frameworks, build tools, testing, ORM, CSS, CI/CD, and more. |
| recommend | Recommending global resources via stack-recommender. I'll map your detected stack to relevant skills, agents, rules, and an archetype. |
| docs | Generating codebase documentation via deepinit. I'll create hierarchical AGENTS.md files across your directories. |
| context | Deep codebase mapping via parallel agents (@architect, @convention-extractor, @explore). I'll synthesize architecture and conventions into durable context and upgrade your project agents. |
| verify | Validating configuration via @verifier. I'll check file existence, config syntax, parent refs, and gitignore. |
| refresh | Updating existing config. I'll preserve your manual edits and merge new detections. Use --full for deep codebase re-mapping and context refresh. |
| status | Showing init state and checkpoint progress. |
| map-codebase | Mapping existing codebase. I'll spawn parallel agents to analyze stack, architecture, and conventions. |
| doctor | Running Hubs health diagnostics. I'll validate installation, config integrity, and state consistency. |
| reset | Resetting project state. I'll archive .opencode/state and .opencode/context to a timestamped backup and start fresh. |
| provision | Auto-generating .opencode/ agents/skills/tools/rules via provision skill. I'll create project-specific resources from your stack analysis. |
| tag | Auditing global resource tags via tag-resources. I'll scan skills, agents, rules, and archetypes for missing or incomplete tags. |
| find-skills | Searching skill registries for relevant skills for this project. |
| find-agents | Searching agent registries for relevant agents for this project. |
| find-tools | Searching registries and local template catalog for relevant TypeScript tools for this project. |
| find-rules | Searching registries and local template catalog for relevant OpenCode rules for this project. |
Flags modify subcommand behavior and are passed through:
| Flag | Effect | Applies To |
|------|--------|------------|
| --minimal | Essential files only, no docs | setup, refresh |
| --full | Everything including context and routing | setup, refresh |
| --force | Skip "already exists" checks | setup, refresh, docs |
| --language <lang> | Force language, skip detection | setup, detect, refresh |
| --no-detect | Use generic defaults | setup, refresh |
| --no-docs | Skip Phase 4 | setup, refresh |
Default (no flags, setup subcommand): Phases 0-5 + 8 (full scaffold + provision + docs + verify, no deep context capture or routing integration).
With --full: All 9 phases (0-8) including Phase 6 (deep codebase mapping + context capture via parallel agents) and Phase 7 (routing integration validation).
Applies to both setup and refresh. In refresh, all phases run in merge mode — preserving manual edits, diffing existing context, and updating only changed sections.
The three new subcommands — detect, recommend, provision — form a sequential pipeline for intelligent project config generation:
flowchart LR
A[detect] --> B[Stack Fingerprint JSON]
B --> C[recommend]
C --> D[Resource Recommendations]
D --> E[provision]
E --> F[.opencode/ config files]
/init-project detect — runs @stack-detector agent, analyzes every tech dimension (language, framework, build, test, ORM, CSS, CI/CD, infra, etc.), outputs a structured JSON fingerprint saved to .opencode/state/init/stack-fingerprint.json/init-project recommend — runs stack-recommender skill, maps the fingerprint to recommended global resources (skills, agents, rules, archetype), outputs recommendations saved to .opencode/state/init/stack-recommendations.json/init-project provision — runs project-config-composer skill, takes the fingerprint + recommendations, auto-generates .opencode/opencode.jsonc, project-specific rules, and optional agent wrappers/init-project detect && /init-project recommend && /init-project provision
Or when running setup or refresh, the pipeline runs automatically:
setup → detect → recommend → provision (if no existing config) or refresh (merge into existing)refresh → detect → recommend → provision (merges into existing, preserves manual edits)/init-project tag can run before recommend to ensure all global resources have complete tags:
/init-project tag && /init-project recommend && /init-project provision
This ensures the stack-recommender's mapping tables are complete and no resources are missed due to missing tags.
After provision, if the composer reports missing tool or rule templates, run discovery:
/init-project find-tools # Search registries for missing TypeScript tools
/init-project find-rules # Search registries for missing OpenCode rules
These can also run standalone to discover resources for any project, independent of the detection pipeline.
Init state lives in .opencode/state/init/ (gitignored).
| Path | Purpose |
|------|---------|
| .opencode/state/init/init-checkpoint.json | Last completed phase checkpoint |
| .opencode/state/init/init-detection.json | Phase 1 detection results (stack fingerprint) |
| .opencode/state/init/init-plan.json | Phase 2 initialization plan (stack recommendations) |
| .opencode/state/init/provision-checkpoint.json | Phase 4 provisioned artifacts manifest |
| .opencode/state/init/integration-report.md | Phase 7 integration validation report (--full only) |
| .opencode/state/init/init-report.md | Phase 8 final verification report |
| .opencode/state/init/ | All init state files |
{
"lastCompletedPhase": 3,
"timestamp": "2024-01-15T10:30:00Z",
"subcommand": "setup",
"mode": "full",
"files": [
".opencode/opencode.jsonc",
".opencode/AGENTS.md",
".opencode/state/"
]
}
.opencode/state/init/ with timestamps/init-project setup --full completion can trigger /harvest-context offer/init-project docs output feeds into /ideation as project context/init-project verify results can inform /project operations/ideation final plans may reference /init-project detection results| Phase | Agent/Skill | Default | --full | Purpose |
|-------|-------------|---------|--------|---------|
| 0 - Verify | self | ✓ | ✓ | Ensure ~/.config/opencode/ is healthy |
| 1 - Detection | @stack-detector | ✓ | ✓ | Scan project files, detect language/framework/build/test/ORM/CSS/CI |
| 2 - Planning | stack-recommender skill | ✓ | ✓ | Map stack fingerprint to recommended global resources |
| 3 - Configuration | project-config-composer skill | ✓ | ✓ | Create .opencode/opencode.jsonc, project rules, agent wrappers |
| 4 - Provisioning | provision skill | ✓ | ✓ | Generate project-specific agents, skills, tools, rules into .opencode/ |
| 5 - Documentation | deepinit skill | ✓ | ✓ | Hierarchical AGENTS.md across codebase |
| 6 - Context Capture | @architect + @convention-extractor + @explore (parallel) | — | ✓ | Map architecture, extract conventions, map file tree → synthesize into .opencode/context/ → upgrade Phase 4 agents with deep project knowledge |
| 7 - Routing & Integration | self (inline validation) | — | ✓ | Validate agent extends paths, skill frontmatter, tool exports, rule registration, context integrity, config syntax, .gitignore |
| 8 - Verification | @verifier | ✓ | ✓ | Validate completeness, references, config — final health check + integration report |
The effort in Phase 4 scales with the init mode:
--minimal: Create empty directories only--full: Thorough agents with full prompts + project-specific TypeScript tools + comprehensive commands + reusable skills, then Phase 6 upgrades those agents with deep project contextFull project initialization from scratch. Default mode runs phases 0-5 + 8 (scaffold, provision, docs, verify). With --full, all 9 phases run including deep context capture (Phase 6) and routing integration (Phase 7).
Before starting any phases, determine scope:
PROJECT_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
OPENCODE_DIR="$PROJECT_ROOT/.opencode"
GLOBAL_DIR="${OPENCODE_CONFIG_DIR:-$HOME/.config/opencode}"
if [ -d "$OPENCODE_DIR" ] && [ -f "$OPENCODE_DIR/opencode.jsonc" ]; then
IS_RERUN="true"
echo "Existing .opencode/ configuration found — running in refresh mode"
else
IS_RERUN="false"
echo "No .opencode/ found — running initial setup"
fi
if [ -f "$GLOBAL_DIR/AGENTS.md" ] && [ -f "$GLOBAL_DIR/opencode.jsonc" ]; then
GLOBAL_HEALTHY="true"
else
GLOBAL_HEALTHY="false"
echo "WARNING: Global Hubs config incomplete or missing"
fi
If IS_RERUN=true and no --force or --refresh flag was passed, ask:
Question: "This project already has .opencode/ configured. What would you like to do?"
Options:
--force)docs subcommand)Run phases sequentially, saving checkpoints after each phase:
.opencode/opencode.jsonc, project rules, agent wrappers--minimal or --no-docs)--full) — spawn 3 parallel agents, synthesize context, upgrade Phase 4 agents--full) — validate agent inheritance, skill discoverability, tool exports, rule registration, .gitignoreSave checkpoint after each phase to .opencode/state/init/init-checkpoint.json.
On completion, display summary and offer next step:
--minimal: Offer /init-project docs/init-project context to add deep context, or /init-project verify to validate--full: Offer /harvest-context to extract more context, or /project workspace to manage the new setupVerify global Hubs installation and detect project configuration. Phases 0-1 only.
~/.config/opencode/ for essential files.opencode/state/init/init-detection.jsonDelegate Phase 1 to explore agent. See phases/01-detection.md for full detection sequence.
{
"language": "typescript",
"framework": "nextjs",
"packageManager": "npm",
"buildSystem": "tsc",
"directories": ["src", "tests", "docs", ".github"],
"ci": "github-actions",
"confidence": "high"
}
On completion, offer next step: /init-project setup or /init-project docs
Regenerate hierarchical AGENTS.md documentation. Phase 5 only.
.opencode/state/init/init-detection.json — if missing, run detect firstdeepinit skill for documentation generationphases/05-documentation.md for full workflowWhen AGENTS.md files already exist:
<!-- MANUAL --> annotationsOn completion, offer next step: /init-project context or /init-project verify
Deep codebase mapping and context capture. Phase 6 only (same as setup --full Phase 6).
@architect (architecture mapping), @convention-extractor (coding conventions), @explore (file tree + entry points).opencode/context/frameworks/architecture.md, .opencode/context/patterns/conventions.md, .opencode/context/theory.md.opencode/context/decisions.md with extracted architectural decisions.opencode/state/project-memory.json with durable project facts.opencode/agents/*.md with deep project context sectionsphases/06-context-capture.md for full workflow.opencode/context/frameworks/architecture.md — system architecture, module boundaries, data flow.opencode/context/patterns/conventions.md — naming, error handling, testing, import patterns.opencode/context/theory.md — living documentation of how the project works.opencode/context/decisions.md — architectural decision records.opencode/state/project-memory.json — durable cross-session facts.opencode/agents/*.md — agents now contain deep project contextOn completion, offer next step: /init-project verify or /harvest-context
Validate configuration completeness and integrity. Phase 8 only.
--full was used, check Phase 7 integration report passedSee phases/08-verification.md for full verification checklist.
Display verification report:
✓ Project initialized: {project_name}
Created/Updated:
.opencode/opencode.jsonc ✓
.opencode/AGENTS.md ✓
.opencode/rules/*.md 3 files
.opencode/state/ ✓
Verified:
✓ All required files present
✓ Configuration syntax valid
✓ AGENTS.md structure complete
✓ Parent references valid
✓ .gitignore configured (state, sessions, chat-history, node_modules)
✓ Privacy scan — no secrets in context files
✓ State directories created
Update existing configuration, preserving manual edits. Default mode runs phases 0-5 + 8 in merge mode. With --full, all 9 phases run (0-8) including deep codebase re-mapping (Phase 6) and routing integration validation (Phase 7).
.opencode/opencode.jsonc and AGENTS.md<!-- MANUAL --> blocks in AGENTS.md filesAll default behavior PLUS:
@architect — re-analyze architecture, detect new modules/refactored boundaries@convention-extractor — re-extract conventions, detect style changes@explore — re-map file tree, detect new entry points.opencode/context/ files. Update changed sections, preserve unchanged sections, preserve <!-- MANUAL --> blocks.Equivalent to setup with --refresh flag.
List initialization state files and show checkpoint progress. No phases.
STATE_DIR=".opencode/state/init"
echo "=== Init Project State ==="
if [ -f "$STATE_DIR/init-checkpoint.json" ]; then
echo "Last checkpoint:"
cat "$STATE_DIR/init-checkpoint.json"
else
echo "No checkpoint found — project not yet initialized"
fi
echo ""
echo "State files:"
ls -la "$STATE_DIR/" 2>/dev/null || echo " (none)"
echo ""
echo "Detection results:"
if [ -f "$STATE_DIR/init-detection.json" ]; then
cat "$STATE_DIR/init-detection.json"
else
echo " No detection results — run detect first"
fi
Detailed phase documentation is in phases/:
phases/01-detection.md — Language, framework, tooling detectionphases/02-planning.md — Stack recommendation and resource planningphases/03-configuration.md — Scaffolding and opencode.jsonc generationphases/04-provisioning.md — Project-specific agent/skill/tool/rule generationphases/05-documentation.md — Hierarchical AGENTS.md generation via deepinitphases/06-context-capture.md — Deep codebase mapping via parallel agents, context synthesis, agent upgrade (--full only)phases/07-routing.md — Routing integration validation: agent inheritance, skill discoverability, tool exports, rule registration, .gitignore (--full only)phases/08-verification.md — Final validation, health check, integration reportThis command is safe to re-run. It:
<!-- MANUAL --> blocks in AGENTS.md filesIf a phase fails, save checkpoint:
mkdir -p ".opencode/state/init"
echo "{\"lastCompletedPhase\":$COMPLETED_PHASE,\"timestamp\":\"$(date -Iseconds)\"}" > ".opencode/state/init/init-checkpoint.json"
Resume with /init-project setup --force or /init-project refresh.
deepinit skill — Standalone docs generation (called by docs subcommand)remember skill — Context promotion (called by context subcommand)wiki skill — Persistent knowledge base (used by context subcommand)mcp-setup skill — MCP server configurationhubs-doctor skill — Diagnose installation issues/ideation hub — Planning and research/orchestrate hub — Execution patterns/harvest-context hub — Context and artifact extractiontools
Create valid, type-safe TypeScript tools for OpenCode — generates correct boilerplate, typed interfaces, and handler stubs. Use when building new tools for global config or per-project .opencode/tools/.
testing
Explore multiple solution branches in parallel, evaluate each, and recommend the best path. Use when the user explicitly invokes /ideation tree-of-thoughts or asks for "tree of thought" / "branching exploration".
testing
Run multiple independent reasoning passes and find consensus. Use when the decision is critically important, the stakes are high, or the user explicitly requests "run it multiple times" / "check consistency" / "self-consistency".
testing
Optimization by PROmpting — generate candidate prompt variations, test each against a benchmark, and report the best performer. Use when the user invokes /ideation opro or asks for "prompt optimization" / "OPRO".