koko

$npx mdskill add joelhooks/joelclaw/koko

Develop and extend the Koko Elixir/OTP agent for BEAM co-residency with joelclaw.

  • Helps build new GenServers, supervisors, and event handlers in the Koko project.
  • Integrates with Redis channels and joelclaw events for workload implementation.
  • Uses ADR-driven architecture and triggers like 'koko' or 'elixir agent' for guidance.
  • Presents results through debugging OTP supervision trees and comparing shadow executions.

SKILL.md

.github/skills/kokoView on GitHub ↗
---
name: koko
displayName: Koko Development
description: Develop and extend Koko — the Elixir/OTP agent living alongside joelclaw. Covers OTP patterns, Redis bridge protocol, shadow execution, and workload implementation.
version: 1.0.0
author: joel
tags: [elixir, beam, otp, koko, agent]
---

# Koko Development

Use this skill when working on the Koko Elixir project — the BEAM co-resident agent alongside joelclaw.

## When to Use

- Building new GenServers, supervisors, or event handlers in Koko
- Implementing workloads (health pulse, event digest, shadow executor)
- Wiring Koko to new Redis channels or joelclaw events
- Debugging OTP supervision trees or process crashes
- Comparing Koko shadow results against TypeScript equivalents

Triggers: `koko`, `elixir agent`, `beam`, `otp`, `shadow executor`, `koko workload`, `koko event`, `mix`

## Project Location

- **Repo**: `~/Code/joelhooks/koko` ([github.com/joelhooks/koko](https://github.com/joelhooks/koko))
- **Host**: Overlook (Mac Mini M4 Pro), accessible via `ssh joel@panda`
- **AGENTS.md**: Full context in repo root

## ADR Awareness

**Always check relevant ADRs before implementing.** Koko's architecture is ADR-driven.

| ADR | Title | Status | URL |
|-----|-------|--------|-----|
| 0114 | Elixir/BEAM/Jido Migration | proposed | [joelclaw.com/adrs/0114-elixir-beam-jido-migration](https://joelclaw.com/adrs/0114-elixir-beam-jido-migration) |
| 0115 | Koko Project Charter | proposed | [joelclaw.com/adrs/0115-koko-project-charter](https://joelclaw.com/adrs/0115-koko-project-charter) |
| 0116 | Redis Bridge Protocol | proposed | [joelclaw.com/adrs/0116-koko-redis-bridge-protocol](https://joelclaw.com/adrs/0116-koko-redis-bridge-protocol) |
| 0117 | First Workloads | proposed | [joelclaw.com/adrs/0117-koko-first-workloads](https://joelclaw.com/adrs/0117-koko-first-workloads) |
| 0118 | Shadow Executor | proposed | [joelclaw.com/adrs/0118-koko-shadow-executor](https://joelclaw.com/adrs/0118-koko-shadow-executor) |

**Before adding a new workload**: Check ADR-0117 for the workload plan and ADR-0118 for shadow execution patterns.

**Before changing Redis integration**: Check ADR-0116 for the bridge protocol and phase boundaries.

**Before any architectural change**: Propose or update an ADR in `~/Vault/docs/decisions/`.

## Key Constraints

1. **Koko is read-only (Phase 1).** PubSub observer only. No LPUSH drain, no authoritative writes.
2. **Shadow results only.** Write to `joelclaw:koko:shadow:<function>` in Redis or local files. Never to Typesense, Todoist, gateway, or any production state.
3. **If Koko crashes, nothing breaks.** The TypeScript stack doesn't depend on it.
4. **Redis at localhost:6379** — k8s NodePort on Overlook.

## Development Commands

```bash
# Run
cd ~/Code/joelhooks/koko
mix deps.get
mix run --no-halt

# Test
mix test

# Interactive
iex -S mix
Koko.events_seen()

# Format
mix format

# Remote (from another machine)
ssh joel@panda "cd ~/Code/joelhooks/koko && mix run --no-halt"
```

## OTP Patterns to Follow

- **One GenServer per concern** — health checker, event accumulator, shadow runner are separate processes
- **Supervisor strategy**: `one_for_one` unless processes are coupled (then `rest_for_one`)
- **Pattern match event types** in `handle_info` — don't use if/else chains
- **Use `Logger.info("[koko]")`** prefix for all log output
- **Crash early** — let supervisors handle recovery, don't defensive-code around failures

## Implementation Phases

### Phase 1: Passive Observer (current)
- Subscribe to `joelclaw:gateway:events` via PubSub ✅
- Log and classify events ✅
- Next: Add health pulse GenServer (Workload 1 from ADR-0117)

### Phase 2: Dedicated Channel
- Create `joelclaw:koko:events` for claimed work
- TypeScript fans out to Koko: `LPUSH joelclaw:koko:events <payload>`
- Koko writes results to `joelclaw:koko:results`

### Phase 3: Shadow Executor
- Mirror select Inngest functions as Koko GenServers
- Same inputs, parallel execution, compare results
- Shadow log at `joelclaw:koko:shadow:<function>`

### Phase 4: Graduation
- Koko handles a workload more reliably than TypeScript
- Survived 30 days without manual intervention
- DX is enjoyable

More from joelhooks/joelclaw

SkillDescription
add-skillCreate new joelclaw skills with the idiomatic process — repo-canonical, symlinked, git-tracked, slogged. Triggers on 'add a skill', 'create skill', 'new skill', 'canonical skill', 'make a skill for', or any request to formalize a process or domain into a reusable skill.
adr-skillCreate and maintain Architecture Decision Records (ADRs) optimized for agentic coding workflows. Use when you need to propose, write, update, accept/reject, deprecate, or supersede an ADR; bootstrap an adr folder and index; consult existing ADRs before implementing changes; or enforce ADR conventions. This skill uses Socratic questioning to capture intent before drafting, and validates output against an agent-readiness checklist.
agent-discovery"Optimize websites, docs, and product surfaces for agent discoverability and operator UX. Use when working on agent SEO/AEO/GEO, crawl policy, markdown or JSON projections, llms.txt, sitemap.md, AGENTS.md guidance, content negotiation, accessibility for browser agents, or any request to make a site easier for pi, OpenCode, Claude Code, ChatGPT, Perplexity, or other agent harnesses to find and use."
agent-loopStart, monitor, and cancel durable multi-agent coding loops via Inngest. Use when the user wants to run autonomous coding workloads, execute a PRD with multiple stories, kick off an AFK coding session, have agents implement features from a plan, or manage running loops. Triggers on "start a coding loop", "run this PRD", "implement these stories", "go AFK and code this", "check loop status", "cancel the loop", "joelclaw loop", or any request for autonomous multi-story code execution.
agent-mail>-
agent-workloads"Compatibility alias for the canonical `workflow-rig` front door. Use when older prompts mention `agent-workloads` or when you need the legacy workload-planning guidance; for new work, load `workflow-rig` first."
clawmail>-
cli-design"Design and build agent-first CLIs with HATEOAS JSON responses, context-protecting output, and self-documenting command trees. Use when creating new CLI tools, adding commands to existing CLIs (joelclaw, slog), or reviewing CLI design for agent-friendliness. Triggers on 'build a CLI', 'add a command', 'CLI design', 'agent-friendly output', or any task involving command-line tool creation."
codex-prompting"Use this skill for any request to trigger, coordinate, or craft prompts for Codex. Use when user says 'send to codex', 'use codex', 'prompt codex', 'ask codex', 'delegate to codex', 'run in codex', or asks for a Codex-first execution handoff."
content-publish"Publish content to joelclaw.com via the Convex-first pipeline. Covers the full lifecycle: draft → review → publish → revalidate → verify. Handles secret leasing, tag conventions, content types (article, tutorial, note, essay), and verification gates. Use when: 'write article about X', 'publish article <slug>', 'draft a tutorial', 'publish this', 'push to convex', or any content publishing task."