# gstack-opencode

Garry Tan's gstack ported to OpenCode. Complete AI engineering workflow with 27 skills.

## What's Included

### Sprint Skills (20)
| Skill | What it does |
|-------|-------------|
| `/office-hours` | YC Office Hours — reframes your product idea |
| `/plan-ceo-review` | CEO review — find the 10-star product |
| `/plan-eng-review` | Eng manager — lock architecture, data flow, tests |
| `/plan-design-review` | Designer review — rate each dimension 0-10 |
| `/design-consultation` | Build a design system from scratch |
| `/review` | Staff engineer — find bugs that pass CI |
| `/ship` | Release engineer — tests, push, PR |
| `/land-and-deploy` | Merge PR, CI, deploy, verify |
| `/qa` | QA lead — browser testing, fix bugs |
| `/qa-only` | QA reporter — bug report only |
| `/design-review` | Designer audit + auto-fix |
| `/canary` | SRE — post-deploy monitoring |
| `/benchmark` | Performance engineer — Core Web Vitals |
| `/document-release` | Technical writer — update docs |
| `/retro` | Eng manager — weekly retro |
| `/investigate` | Debugger — systematic root-cause |
| `/cso` | Security officer — OWASP + STRIDE |
| `/codex` | Second opinion — OpenAI Codex review |
| `/autoplan` | Auto-review pipeline |
| `/setup-deploy` | Deploy configurator |

### Safety Skills (4)
| Skill | What it does |
|-------|-------------|
| `/careful` | Warn before destructive commands |
| `/freeze` | Lock edits to one directory |
| `/guard` | Full safety: careful + freeze |
| `/unfreeze` | Remove freeze restriction |

### Browse Skills (8)
| Skill | What it does |
|-------|-------------|
| `/browse` | Headless Chromium — ~100ms/command |
| `/setup-browser-cookies` | Import cookies from real browser |
| `/qa` | Browser-based QA testing |
| `/design-review` | Visual audit with screenshots |
| `/canary` | Monitor deployed app |
| `/benchmark` | Performance baselines |
| `/land-and-deploy` | Post-deploy verification |
| `/setup-browser-cookies` | Session management |

## Installation

### Prerequisites
- [OpenCode](https://opencode.ai)
- [Bun](https://bun.sh) v1.0+
- [Git](https://git-scm.com/)

### Quick Install

```bash
# Clone this repo
git clone https://github.com/your-username/gstack-opencode.git ~/gstack-opencode

# Run setup
cd ~/gstack-opencode && ./setup

# Add to your shell profile
echo 'source ~/gstack-opencode/bin/gstack-env.sh' >> ~/.zshrc
source ~/.zshrc
```

### Manual Install

```bash
# 1. Clone gstack
git clone https://github.com/garrytan/gstack.git ~/gstack-opencode/source

# 2. Build browse
cd ~/gstack-opencode/source
bun install
bun build --compile browse/src/cli.ts --outfile ~/gstack-opencode/browse/dist/browse

# 3. Link skills to OpenCode
mkdir -p ~/.config/opencode/skills/gstack
ln -sf ~/gstack-opencode/skills/* ~/.config/opencode/skills/gstack/
```

## Directory Structure

```
~/gstack-opencode/
├── skills/                    # 27 OpenCode skills
│   ├── office-hours/SKILL.md
│   ├── review/SKILL.md
│   ├── browse/SKILL.md
│   └── ...
├── browse/                    # Headless browser engine
│   └── dist/browse            # Compiled binary (63MB)
├── bin/                       # Tool scripts
│   ├── gstack-env.sh          # Environment setup
│   ├── gstack-slug            # Generate repo slug
│   └── ...
├── plugin/                    # OpenCode plugin
│   └── gstack-guardian.js     # Safety mechanism
├── review/                    # Shared assets
│   ├── checklist.md
│   └── ...
├── ETHOS.md                   # Builder philosophy
├── BROWSER.md                 # Browser command reference
├── setup                      # Installation script
└── README.md                  # This file
```

## Environment Variables

| Variable | Description |
|----------|-------------|
| `GSTACK_OPENCODE_DIR` | Path to gstack-opencode directory |
| `GSTACK_BROWSE` | Path to browse binary |

## Safety Mechanism

The `/careful`, `/freeze`, and `/guard` skills are implemented as an OpenCode plugin (`plugin/gstack-guardian.js`). It intercepts:

- **Destructive commands:** `rm -rf`, `DROP TABLE`, `git push --force`, etc.
- **Freeze violations:** Edits outside the locked directory

## Differences from Original gstack

| Aspect | Claude Code | OpenCode |
|--------|-------------|----------|
| Hook mechanism | PreToolUse hooks | Plugin `tool.execute.before` |
| Environment vars | `${CLAUDE_SKILL_DIR}` | `${GSTACK_OPENCODE_DIR}` |
| Safety skills | Shell scripts | JavaScript plugin |
| Skill format | YAML + Markdown | YAML + Markdown (simplified) |

## Credits

Original gstack by [Garry Tan](https://github.com/garrytan/gstack) — MIT License

OpenCode port by gstack-opencode contributors

## License

MIT
