Development
This page is for people working on Yak itself: fixing bugs, adding features, writing a new channel, or improving these docs. To run Yak against your repos, see Setup.
Local Setup
Section titled “Local Setup”Prerequisites
Section titled “Prerequisites”| Tool | Version | Used for |
|---|---|---|
| PHP | 8.5 | The Laravel app. composer.json allows ^8.3, but CI and the project target 8.5. Needs pdo_mysql and the redis extension (the config uses phpredis) |
| Composer | 2.x | PHP dependencies |
| Node | 22 | Frontend build, Playwright, and the runner. CI uses 22. runner/package.json allows >=20 |
| Docker | 24+ | MariaDB (and Redis) through docker compose |
| Go | 1.26 | broker/ and cli/, only when you change them |
You do not need Incus, Ansible, the Claude CLI or a Chromium for the Laravel app. Tests replace the sandbox and the broker with fakes.
Services
Section titled “Services”| Service | Needed locally? | Notes |
|---|---|---|
| MariaDB | Yes | docker compose up -d mariadb starts it on 127.0.0.1:3306 (database, user and password yak). A second service, mariadb-test, listens on 3307 for tests that want a real MariaDB |
| Redis | For thread turns and some tests | Thread turns talk to the broker through Redis streams (BrokerStreams). Sessions, cache and queue use the database. CI runs a Redis 7 service. Tests that do not touch the real streams use a fake |
| Reverb | No | Leave REVERB_APP_KEY empty and the thread page polls over HTTP. composer run dev does not start it. The browser tests use a Reverb test environment (yak-e2e-* on 127.0.0.1:18080, see .env.example) |
| Broker, runner, Incus | No | Real sandboxes need a Linux host with Incus. Locally you work on the dashboard, the jobs and the tests, which use fakes |
Getting Started
Section titled “Getting Started”git clone https://github.com/geocodio/yak.gitcd yakcp .env.example .envdocker compose up -d mariadbcomposer run setup # install, key:generate, migrate, npm install, npm run buildcomposer run setup copies .env.example when .env is missing, so the cp line is optional.
Running The App
Section titled “Running The App”composer run devThis runs four processes together with concurrently: php artisan serve, php artisan queue:listen --tries=1 --timeout=0, php artisan pail --timeout=0 (logs) and npm run dev (Vite). It does not start the scheduler, Reverb or the thread drivers. Start them in their own terminals when you need them: php artisan schedule:work, php artisan reverb:start, php artisan yak:thread-drivers.
Open http://localhost:8000. Login is Google-only, so visit http://localhost:8000/letmein. In a local environment it signs you in as the first user (creating one if there is none) and lands on home: the most recent thread, or the Welcome page on an empty database. The route does not exist in other environments.
Repository Layout
Section titled “Repository Layout”| Path | What lives there |
|---|---|
app/Channels/<Name>/ | One folder per channel (Slack, Linear, Sentry, Email, GitHub, Drone): entry class, drivers, webhook controllers, health check |
app/Channels/Contracts/ | Capability interfaces: InputDriver, NotificationDriver, CIDriver, CIBuildScanner |
app/Services/Threads/ | Thread and turn machinery: ThreadTurns, ThreadCommands, ThreadDriver, TurnFinisher, RunawayGuard, the broker streams and the sandbox managers |
app/Services/Stacks/, app/Services/Threads/Repos/ | Sub-thread stacks and multi-repo threads |
app/Jobs/ | Queued jobs. Jobs that start a turn share Jobs/Concerns/StartsThreadTurns. Middleware is in app/Jobs/Middleware/ |
app/Http/Controllers/, app/Http/Resources/ | Controllers return Inertia::render(...). *Data resources shape the props |
app/Prompts/, app/YakPromptBuilder.php, resources/views/prompts/ | Prompt definitions, prompt assembly and the Blade defaults. See Prompting |
resources/js/pages/<Area>/<Name>.tsx | Inertia pages (React 19, TypeScript) |
resources/js/components/, layouts/, types/ | Shared components, layouts, and types that mirror the PHP *Data shapes |
resources/js/routes/, resources/js/actions/ | Wayfinder output. Never edit by hand |
broker/ | yak-broker (Go): moves messages between Redis streams and the sandbox runner, runs the auth proxy. Wire format in broker/PROTOCOL.md |
runner/ | The Node runner that wraps the Claude Agent SDK inside each sandbox |
cli/ | The yak command-line tool (Go). See CLI |
plugin/ | The Claude Code plugin. See CLI |
sandbox-tools/ | Tools baked into the sandbox image, such as yak-browser |
schemas/ | JSON schemas for .yak/config.yml, preview.yml and risk-profile.yml |
ansible/, docker/, Dockerfile | Production provisioning. docker/supervisord.conf is off limits without approval |
docs/, docs-site/ | The documentation and the site that renders it |
See Architecture for how a turn moves through these parts.
Running Tests
Section titled “Running Tests”Laravel App (Pest)
Section titled “Laravel App (Pest)”# What CI runs for the main suitevendor/bin/pest --parallel --processes=4 --exclude-group=contract,browser
# One file, one testphp artisan test --compact tests/Feature/Threads/FakeSandboxManagerTest.phpphp artisan test --compact --filter="creates a task when a valid Sentry webhook arrives"A full local run can exhaust PHP’s default 128M memory limit. Raise it: php -d memory_limit=2048M vendor/bin/pest. phpunit.xml already sets 2048M for the test process.
Feature tests use SQLite in memory through RefreshDatabase (set globally in tests/Pest.php), with QUEUE_CONNECTION=sync and the array cache. Always create data with factories.
Test Fakes
Section titled “Test Fakes”tests/Pest.php binds fakes so that thread tests never reach Incus or the broker:
| Fake | Replaces | Use it when |
|---|---|---|
FakeSandboxManager | SandboxManager | A test starts, wakes or stops a thread sandbox |
FakeBrokerStreams | BrokerStreams (Redis streams) | A test sends commands to the runner or feeds runner output to the thread driver. Assert on the commands it recorded |
FakeSessionFileSync | SessionFileSync | A test would copy session transcripts |
A test of the Redis implementation itself builds RedisBrokerStreams directly. Use Http::fake() for external APIs and Process::fake() for git and shell calls (specific patterns before wildcards).
Browser Tests
Section titled “Browser Tests”Browser tests drive a real Chromium through Pest’s Playwright plugin. Target data-testid hooks.
npx playwright install --with-deps chromium # first timenpm run build # the tests need built assetsvendor/bin/pest tests/BrowserCI runs them in four shards (--shard=N/4) against the Reverb test environment.
Contract Tests
Section titled “Contract Tests”Tests in the contract group are meant to run against the real Claude CLI and are excluded from every other run. The tests/Contract/ folder is currently empty. The nightly workflow installs the CLI and runs vendor/bin/pest --group=contract.
Broker, CLI And Runner
Section titled “Broker, CLI And Runner”cd broker && go vet ./... && go test -race ./...cd cli && go vet ./... && go test -race ./...cd runner && npm ci && npm test # node --test tests/*.test.mjsCI Workflows
Section titled “CI Workflows”| Workflow | Runs | What it does |
|---|---|---|
tests.yml | Push and PR | Pest, parallel, excluding contract and browser. PHP 8.5, Node 22, a Redis service |
browser.yml | Push and PR | tests/Browser in four shards with Playwright Chromium |
lint.yml | Push and PR | Pint, PHPStan (--memory-limit=2G), npx tsc --noEmit, gofmt and go vet for broker/ and cli/ |
broker.yml | Changes under broker/ | go vet, gofmt check, go test -race |
cli.yml | Changes under cli/ | Same checks for the CLI |
runner.yml | Changes under runner/ | Node 22, npm ci, npm test |
contract-tests.yml | Nightly | pest --group=contract with the real Claude CLI |
docker.yml | Push | Builds and pushes the Docker image |
docs.yml | Push to main touching docs | Builds the docs site and deploys it to GitHub Pages |
release.yml, cli-release.yml | Tags | Release the app, and build the yak CLI for release |
Code Style
Section titled “Code Style”All of these run in CI (lint.yml).
vendor/bin/pint # fix PHP stylevendor/bin/phpstan analyse # level 8, Larastannpx tsc --noEmit # TypeScriptgofmt -l broker cli # must print nothingPint uses the Laravel preset with concat_space set to one. phpstan-baseline.neon holds pre-existing errors: do not clear it, and do not add to it. Spell identifiers out in full (isPayAsYouGo, not isPAYG).
Wayfinder
Section titled “Wayfinder”Routes and controller actions are exposed to React through generated helpers in resources/js/routes and resources/js/actions. After you change a route, run:
php artisan wayfinder:generateThe Vite plugin also regenerates them during npm run dev and npm run build. Never edit the output by hand.
Adding A Channel
Section titled “Adding A Channel”A channel is an integration: a way tasks arrive, notifications leave, or CI results come in. Each channel lives in app/Channels/<Name>/ and implements App\Channels\Channel. Read a small existing channel first: app/Channels/Email/ (input only) or app/Channels/Drone/ (CI polling only).
The Parts
Section titled “The Parts”| Part | Contract | Purpose |
|---|---|---|
Entry class <Name>Channel | Channel | Names the channel (name(), which matches the source on a task and the config('yak.channels.<name>') key), lists requiredConfig(), registers routes, and returns the drivers it has (or null) |
| Input driver | InputDriver::parse(Request): TaskDescription | Turns a webhook into a task description |
| Notification driver | NotificationDriver::send(YakTask, NotificationType, string): void | Posts acknowledgments, progress, results and errors back to the source |
| CI driver | CIDriver::parse(Request): BuildResult | Parses a CI webhook |
| CI build scanner | CIBuildScanner::getRecentFailures(Repository, int): Collection | For CI systems that must be polled |
| Health check | HealthCheck | Shown on the health page |
The ChecksRequiredConfig trait implements enabled() and config(): a channel is enabled when every key in requiredConfig() has a value.
- Add
config/yak.phpentries underchannels.<name>, reading from env vars. - Create
app/Channels/<Name>/<Name>Channel.phpand the drivers it needs. Returnnullfor the capabilities it does not have. - If the channel receives webhooks, add an invokable controller that uses the
VerifiesWebhookSignaturetrait, and register the route inregisterRoutes()(routes live under thewebhooksprefix, only for enabled channels). - Add the entry class to
channel_classesinconfig/yak.php.ChannelServiceProviderregisters every class there in theChannelRegistry. - If the source needs its own task prompt, add a Blade template in
resources/views/prompts/tasks/, declare it inapp/Prompts/PromptDefinitions.php, add a sample toPromptFixtures, and route the source to it inYakPromptBuilder::taskPrompt(). - Add provisioning in
ansible/if the channel needs setup on the host. - Write tests under
tests/Feature/Channels/<Name>/(valid payload creates a task, bad signature is rejected, duplicates are ignored,Http::fake()for outbound calls). - Document the channel in Channels.
Working On The Docs
Section titled “Working On The Docs”The documentation is flat Markdown in docs/, one file per page, with lowercase kebab-case names. The first line is # Page Title, with no front matter. Link to other pages as [text](/yak/name/) or [text](/yak/name/#anchor).
- New page: add it to the
PAGESlist indocs-site/scripts/sync-docs.mjs(a file that is not listed is skipped), and to the sidebar indocs-site/astro.config.mjs. - Preview locally: run
cd docs-site && npm install && npm run dev, then openhttp://localhost:4321/yak/. The dev server syncsdocs/into the site on start. Do not editdocs-site/src/content/docs/, it is regenerated.npm run buildbuilds the site andnpm run previewserves the build. Seedocs-site/README.md. - Screenshots: images sit at the top level of
docs/and are namedscreenshot-<slug>.png. Make them with dummy data only (repos likeacme/storefront, people like Ada and Grace, hostyak.example.com), never real customers, repos, hosts or tokens. - Style: short sentences, no em dashes, and describe Yak as opening PRs for review and serving previews.
Pull Request Process
Section titled “Pull Request Process”-
Fork the repo and branch off
main. -
Make your change with tests.
-
Run the pre-flight checks:
Terminal window vendor/bin/pintvendor/bin/phpstan analysevendor/bin/pest --parallel --processes=4 --exclude-group=contract,browserAlso run the Go and runner tests if you touched
broker/,cli/orrunner/. -
Open a PR with the template in
.github/pull_request_template.md. -
A maintainer reviews it and merges once CI is green.
Do Not Touch Without Approval
Section titled “Do Not Touch Without Approval”phpstan-baseline.neon: pre-existing errors, do not clear.docker/supervisord.conf: production config..chief/: local working files, never commit.- Ansible vault and inventory files: the repo is public, never commit them.
Reporting Bugs And Requesting Features
Section titled “Reporting Bugs And Requesting Features”- Bug report:
https://github.com/geocodio/yak/issues/new?template=bug_report.yml - Feature request:
https://github.com/geocodio/yak/issues/new?template=feature_request.yml
Include the Yak version (git SHA), the channel involved, steps to reproduce, and relevant logs.