A structured, opinionated workflow for building software with OpenCode. It takes you from an idea, through a PRD and project rules, into context-rich plans and one-pass implementations — and gives every new session a clean way to load project context.
┌────────────────────────┐
Conversation ─────► │ /create-prd PRD.md │ ── PRD.md
└─────────────┬──────────┘
│
▼
┌────────────────────────┐
Existing codebase ► │ /create-rules │ ── AGENTS.md
└─────────────┬──────────┘
│
▼
┌────────────────────────┐
Feature request ──► │ /plan-feature <name> │ ── .agents/plans/<name>.md
└─────────────┬──────────┘
│
▼
┌────────────────────────┐
│ /execute <plan-path> │ ── code + tests
└─────────────┬──────────┘
│
▼
┌────────────────────────┐
│ /commit │ ── atomic commit
└────────────────────────┘
New session? ───► /prime (load project context first)
.opencode/
├── AGENTS-template.md # Template used by /create-rules
├── agents/ # Specialized subagents (codebase-mapper, researcher, security-auditor)
├── commands/ # Slash commands that drive the flow
│ ├── prime.md
│ ├── create-prd.md
│ ├── create-rules.md
│ ├── init-project.md
│ ├── plan-feature.md
│ ├── execute.md
│ └── commit.md
└── skills/ # Skills auto-loaded for matching tasks
├── agent-browser/
├── doc-coauthoring/
├── e2e-test/
└── excalidraw-diagram/
Everything is defined as plain Markdown — commands, agents, and skills are all editable in place.
- Context is king. A plan must contain everything the implementation agent needs — patterns, files to read, validation commands — so it can succeed on the first attempt.
- Plan before code.
/plan-featurenever writes implementation code. It produces a plan rich enough for/executeto follow blindly. - Rules over reminders. Project conventions live in
AGENTS.md, not in every prompt. - Prime every session. New sessions start by loading context, not guessing.
Use this at the very start of a new product or major initiative.
- Input: the current conversation (requirements, goals, constraints).
- Output: a comprehensive PRD (default
PRD.md) with 15 standard sections — executive summary, mission, target users, MVP scope, user stories, architecture, tech stack, security, success criteria, implementation phases, risks, etc. - When to use: before any code exists, or when scoping a brand-new product surface.
/create-prd PRD.md
The command will ask clarifying questions if critical information is missing, then write a single Markdown file you can review and refine.
Once a codebase (even a scaffold) exists, generate the global rules file that every future agent session will read.
- Input: the current codebase (configs, directory layout, existing patterns).
- Output:
AGENTS.mdat the project root, based on.opencode/AGENTS-template.md. - Covers: project overview, tech stack, dev/build/test commands, structure, naming and error-handling patterns, key files.
/create-rules
AGENTS.md is the single source of truth for "how we work here." Keep it short and scannable — link out to deeper docs instead of duplicating them.
A project-specific runbook for getting the app running locally (env file, deps, database, migrations, dev server, health checks).
/init-project
Edit .opencode/commands/init-project.md to match your stack — it ships as a reference example.
This is where most of your time should be spent. The command runs a 5-phase planning process:
- Feature understanding — problem, value, complexity, user story.
- Codebase intelligence — structure, patterns, dependencies, tests, integration points (uses subagents in parallel).
- External research — official docs, best practices, gotchas, with linked references.
- Strategic thinking — trade-offs, edge cases, performance, security.
- Plan generation — fills the full template: context references, phased implementation plan, step-by-step tasks with
IMPLEMENT / PATTERN / IMPORTS / GOTCHA / VALIDATE, testing strategy, validation commands, acceptance criteria.
/plan-feature add user authentication
- Output:
.agents/plans/<kebab-case-name>.md(e.g.add-user-authentication.md). - Rule: no code is written in this phase. The plan is the deliverable.
A good plan passes the "no prior knowledge" test — a fresh agent should be able to implement it using only the plan.
Hand the plan to an execution session.
/execute .agents/plans/add-user-authentication.md
The execute command:
- Reads the entire plan and understands task dependencies.
- Works tasks in order, mirroring referenced patterns.
- Implements the testing strategy.
- Runs every validation command from the plan; fixes failures before moving on.
- Reports completed tasks, created/modified files, test results, and validation output.
Deviations from the plan are documented in the report rather than silently applied.
When the execute report says "Ready for Commit," wrap it up:
/commit
This inspects git status / git diff HEAD, stages the relevant files, and creates an atomic commit with a conventional tag (feat, fix, docs, …).
Every new OpenCode session starts with zero project context. Run /prime first.
/prime
prime will:
- List tracked files (
git ls-files) and show the directory tree. - Read
PRD.md,AGENTS.md(orCLAUDE.md), root and major-dir READMEs, architecture docs, and DB/schema configs. - Read entry points and core configs (
package.json,pyproject.toml,tsconfig.json, etc.). - Check recent git activity (
git log -10 --oneline,git status). - Return a concise summary: project overview, architecture, tech stack, conventions, current state.
Use it whenever:
- You open a fresh session.
- You switch to a branch you haven't worked on recently.
- You hand off context to a teammate or a new agent.
Greenfield project
1. /create-prd PRD.md # capture the product
2. /init-project # (after scaffold exists) verify local setup
3. /create-rules # generate AGENTS.md once the scaffold is in
4. /plan-feature <first slice> # plan the first vertical slice
5. /execute .agents/plans/<...>.md # implement it
6. /commit # ship it
Existing project, new feature
1. /prime # load context
2. /plan-feature <feature> # produce the plan
3. /execute .agents/plans/<...>.md # implement
4. /commit # ship it
Coming back the next day
1. /prime
2. continue from where /execute left off, or start /plan-feature for the next slice
/plan-feature always structures work into four implementation phases:
- Foundation — schemas, types, configuration, helpers.
- Core Implementation — business logic, services, models, endpoints.
- Integration — wire into existing routers/handlers/middleware/config.
- Testing & Validation — unit, integration, edge cases, acceptance.
Inside the phases, every task uses information-dense verbs (CREATE, UPDATE, ADD, REMOVE, REFACTOR, MIRROR) and includes:
IMPLEMENT— what to do.PATTERN— the file:line to mirror.IMPORTS— required imports.GOTCHA— constraints to avoid.VALIDATE— an executable command.
/execute follows these top-to-bottom and validates as it goes. If validation fails, it fixes the issue and re-runs before moving on.
Beyond the commands above, the flow uses:
Subagents (in .opencode/agents/)
codebase-mapper— high-level structural overview of a repo.researcher— best-practice and library research.security-auditor— vulnerability and security review.
Skills (in .opencode/skills/) auto-load when a task matches their description.
agent-browser— browser automation, screenshots, form filling, scraping.doc-coauthoring— structured doc-writing workflow.e2e-test— full end-to-end test runs with browser + DB validation.excalidraw-diagram— produce Excalidraw diagrams.
You don't normally invoke these directly — /plan-feature and /execute will pull them in as needed, and skills load automatically.
- Keep
AGENTS.mdshort. Link to deeper docs rather than duplicating them. - Re-run
/create-rules(or hand-editAGENTS.md) when conventions drift. - Treat plans in
.agents/plans/as artifacts — commit them so future sessions can reference them. - Don't skip
/primeon new sessions. The minute you save is paid back many times over. - If a plan feels thin, ask
/plan-featureto revise — better to iterate on the plan than to debug a bad execution.