# opencode-plugin-coding

A shared [OpenCode](https://opencode.ai) plugin for multi-agent software development workflows. Provides skills, guides, and file-based agents that standardize the full cycle: brainstorm, plan, implement, review, debug, and retrospect.

Agents are defined as markdown files (`~/.config/opencode/agents/*.md` for global, `.opencode/agents/*.md` for project-level). The plugin provides the skills, guides, and commands — you own the agent files.

## Skills

| Skill | Description |
|-------|-------------|
| `brainstorm` | Socratic design interview that refines rough ideas into a validated design document |
| `plan` | Decomposes a design into bite-sized implementation tasks with file paths and acceptance criteria |
| `orchestrate` | Full multi-agent workflow: implement → review → merge → retrospective |
| `test-driven-development` | RED-GREEN-REFACTOR cycle enforcement |
| `systematic-debugging` | 4-phase debugging: reproduce → hypothesize → isolate → fix |
| `git-worktree` | Create and manage isolated git worktrees for parallel development |
| `playwright` | Browser automation via Playwright MCP server |

## Commands

| Command | Description |
|---------|-------------|
| `/zooplankton-coding-init` | Auto-detect project, generate `zooplankton.json` and agent MD files |
| `/zooplankton-coding-update` | Check schema updates, refresh agent MD files from latest guides |
| `/zooplankton-orchestrate` | Run the full orchestrate workflow (implement → review → merge → retrospective) |

## Guides

Guide files define the prompt and behavior for each agent role. Each role has two platform variants (`-github.md` and `-local.md`). When you run `/zooplankton-coding-init`, the guide content is baked into your agent MD files. Run `/zooplankton-coding-update` to refresh them from the latest guides.

| Guide | GitHub variant | Local variant |
|-------|---------------|---------------|
| Core coder | `core-coder-guide-github.md` | `core-coder-guide-local.md` |
| Core reviewer | `core-reviewer-guide-github.md` | `core-reviewer-guide-local.md` |
| Normal reviewer | `reviewer-guide-github.md` | `reviewer-guide-local.md` |
| Security reviewer | `security-reviewer-guide-github.md` | `security-reviewer-guide-local.md` |
| Frontend coder | `frontend-coder-guide-github.md` | `frontend-coder-guide-local.md` |
| Frontend reviewer | `frontend-reviewer-guide-github.md` | `frontend-reviewer-guide-local.md` |

## Setup

### 1. Install the plugin globally (recommended)

Add the plugin to `~/.config/opencode/opencode.json` to make it available across all projects:

```json
{
  "$schema": "https://opencode.ai/config.json",
  "plugin": [
    "opencode-plugin-coding"
  ]
}
```

OpenCode auto-installs the plugin from npm via Bun at startup.

### Pin a specific version (optional)

```json
"plugin": ["opencode-plugin-coding@0.5.0"]
```

### Project-level installation (alternative)

To restrict the plugin to a single project, add the same `plugin` entry to `opencode.json` in the project root instead of `~/.config/opencode/opencode.json`.

### 2. Run /zooplankton-coding-init

From your project root in OpenCode, run:

```
/zooplankton-coding-init
```

This will:
- Auto-detect project settings (language, framework, package manager, commands)
- Generate `zooplankton.json` with project configuration and agent name list
- Generate agent MD files (`~/.config/opencode/agents/*.md` for global, `.opencode/agents/*.md` for project)
- Update `.gitignore` for ephemeral plugin files

### 3. Configure agents

Agent MD files contain the model, permissions, and guide prompt for each agent. They are generated by `/zooplankton-coding-init` using the appropriate `guides/<role>-guide-<platform>.md` variant.

To change a model: edit the `model:` field in the agent's MD frontmatter directly.  
To add/remove agents: run `/zooplankton-coding-update` or create/delete agent MD files manually.  
To refresh guide content: run `/zooplankton-coding-update`.

> **How it works:** The plugin uses OpenCode's `config` hook to register skills via `config.skills.paths` and commands via `config.command`. Agents are file-based — the plugin does not dynamically register agents.

## Project-Level Files

After `/zooplankton-coding-init`, your project will have:

| File | Committed? | Purpose |
|------|-----------|---------|
| `zooplankton.json` | Yes | Project configuration + agent name list |
| `zooplankton-local.json` | No (gitignored) | User-specific GitHub account mapping |
| `~/.config/opencode/agents/*.md` or `.opencode/agents/*.md` | Yes (your call) | Agent files with model, permissions, guide |
| `.opencode/reviewer-knowledge.json` | No (gitignored) | Adaptive reviewer scoring cache |
| `.plans/<branch>.md` | Yes | Plan files — committed for analysis |
| `.plans/<branch>-retro.md` | Yes | Retrospective files — committed for analysis |

## Configuration

`zooplankton.json` schema:

```json
{
  "project": {
    "name": "my-project",
    "repo": "Org/my-project",
    "defaultBranch": "master",
    "platform": "github",
    "githubEnterpriseHosts": []
  },
  "stack": {
    "language": "typescript",
    "framework": "react",
    "packageManager": "yarn"
  },
  "commands": {
    "build": "yarn build",
    "lint": "yarn lint",
    "test": "yarn test",
    "typecheck": "npx tsc --noEmit"
  },
  "agents": {
    "coreCoder": { "name": "core-coder" },
    "coreReviewers": [
      { "name": "core-reviewer-primary" },
      { "name": "core-reviewer-secondary" }
    ],
    "reviewers": [
      { "name": "reviewer-glm" },
      { "name": "reviewer-minimax" }
    ],
    "securityReviewers": [],
    "frontendCoder": null,
    "frontendReviewers": []
  },
  "autonomousMode": false,
  "testDrivenDevelopment": { "enabled": false },
  "docsToRead": ["AGENTS.md"],
  "reviewFocus": ["type safety", "error handling"]
}
```

> **Model configuration:** Models are set in agent MD files (`model:` frontmatter field), not in `zooplankton.json`. The `agents` block is **optional** — omit it entirely and the orchestrate skill will discover your agents from MD files automatically. Only add it when you need to override defaults (disable a role, restrict which agents run, or use a non-standard agent name).

To enable frontend agents, replace the `null`/`[]` values with agent name objects:

```json
"frontendCoder": { "name": "frontend-coder" },
"frontendReviewers": [
  { "name": "frontend-reviewer-primary" }
]
```

## License

MIT
