The OpenCode Framework enforces a high-discipline development lifecycle. Whether you are a human or an AI contributor, adherence to these standards is mandatory.
Every non-trivial change must follow this strict three-phase process:
[Phase 1: Discovery] -> [Phase 2: Strategy] -> [Phase 3: Execution]
(Audit/Research) (Planning Bridge) (Tasks/Drafting)
Before proposing a change, you must gather context and identify risks. Use the specialized discovery commands:
/research: For domain knowledge and external libraries./audit: To audit the codebase for technical debt and architecture issues./debug: To perform a root-cause analysis (RCA) on a bug.
Crucially, these commands are read-only; they produce artifacts (.knowledge/notes/, *.review.md), not code changes.
A feature or fix is not considered "active" until a persistent Markdown plan has been created in the .knowledge/plans/ directory. Use the /plan command to synthesize the artifacts generated in Phase 1 into an actionable strategy.
Once a plan is approved, you move to execution. This is the only phase where files are modified.
The /task command is the primary tool for repository execution:
task add: Adds a new task using thetasktool.task start --task-id X: Marks a task as in-progress.task list: Provides a summary of the roadmap and current priorities.task archive --task-id X: Marks a task as done.
CLI-First Roadmap Discipline:
The project roadmap (tasks.yaml) must never be edited by hand. All task operations must be performed via the task tool or the corresponding /task actions. This ensures structural integrity and a verifiable audit trail.
- Phase 1 (Pre-flight Verification): The agent verifies that the working tree is clean, the current branch is
main, andmake testpasses as a baseline. - Phase 2 (Task Isolation): A dedicated feature branch (e.g.,
feature/task-name) is auto-generated and checked out. All work occurs on this isolated branch. - Phase 3 (The Red-Green-Verify Loop): For every granular step of the implementation:
- Red: Write a failing test and verify failure with
make test. - Green: Implement the minimal code to pass the test.
- Verify: Run
make test.- Pass:
git committhe step. - Fail: Attempt one quick fix. If it fails again, the change is automatically reverted (
git checkout .).
- Pass:
- Red: Write a failing test and verify failure with
- Phase 4 (Integration): Once all steps are complete, the agent performs a final test run. Upon approval, the branch is merged into
mainand deleted.
When a bug is detected, the /debug command enforces a structured, scientific investigation:
- Phase 1 (Status & Context): Analyze the current environment and gather reproduction information.
- Phase 2 (Hypothesis Formulation): Formulate a specific hypothesis for the root cause.
- Phase 3 (Isolated Testing): Test the hypothesis on a temporary diagnostic branch (
debug/hyp-*). Diagnostic code should be minimal and focused. - Phase 4 (Synthesis & RCA): Summarize the investigation into a Root Cause Analysis (RCA) report. This report serves as the documentation for the subsequent fix.
Before merging or committing any final change, the work must be documented in the daily journal. This is enforced by a timestamp-based git hook. Use the following tool to satisfy the requirement:
journal add "one-line description of the work"Failure to do this will block your commit or turn execution.
- Automated Context Minification: To ensure maximum token efficiency and prevent context saturation during long sessions, the framework automatically identifies and replaces redundant
<instruction>blocks from previous turns with a placeholder. Only the latest instruction is passed to the model in its full form, ensuring the agent stays focused on the current task while maintaining structural operational context. - Agent-Driven Validation: This project maintains a minimalist, transient testing philosophy. Instead of a static suite of thousands of unit tests, it relies on high-discipline agent execution and Grounded Experimentation to verify behavior in real-time.
- On-the-Fly Verification: During the mandatory TCR (Test-Commit-Revert) loop, the agent is required to write specific, temporary test cases (e.g.,
test_feature_x.py) that verify the granular step being implemented. - Source of Truth: The
makefileis the central definition of project health. Even if it initially points to an emptytesttarget, it serves as the hook point for the agent's automated validation. - The TCR Mandate: The primary mechanism for ensuring "Green-only" development is the mandatory Test-Commit-Revert loop. If a change fails its temporary verification, it is instantly reverted, ensuring the
mainbranch remains a "known-good" state.
The framework requires a clean working tree for critical actions. Commit often to avoid merge conflicts or large, unmanageable diffs.
All commit messages must follow the Conventional Commits standard:
feat:: A new feature for the user (e.g.,feat(hooks): add notify-send alert).fix:: A bug fix for the user.docs:: Documentation-only changes.chore:: Maintenance, dependencies, or internal tooling updates (e.g.,chore(release): version 0.17.1).refactor:: Code changes that neither fix a bug nor add a feature.
When possible, provide a scope to the commit message (e.g., feat(onboard): add documentation discovery).
- Markdown: All documentation and logs must be in GitHub-flavored Markdown.
- Kebab-case: Use kebab-case for all filenames in the
docs/,.knowledge/plans/, and.knowledge/notes/directories. - Direct & Technical: Documentation should be concise, high-signal, and technically rigorous.
Return to the Project Overview.