This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
openTiger is an autonomous coding orchestration system. It continuously ingests requirements/issues, plans tasks, dispatches them to execution agents, judges results, and handles recovery/retry — all under explicit state transitions. The system is recovery-first: non-stalling convergence matters more than one-shot success.
# Full bootstrap (install + docker + db + dev servers)
pnpm run setup && pnpm run up
# Quality checks (run before any PR)
pnpm run check # lint + typecheck
pnpm run check:all # lint + format + typecheck + build
pnpm test # all tests
pnpm test:watch # watch mode
# Single package test
pnpm --filter @openTiger/worker test
pnpm --filter @openTiger/core test
# Linting and formatting
pnpm lint # oxlint
pnpm format # oxfmt
pnpm typecheck # tsc --noEmit
# CI parity (all must pass)
pnpm build && pnpm lint:ci && pnpm typecheck && pnpm test
# Database (Drizzle ORM)
pnpm db:push # push schema (idempotent)
pnpm db:generate # generate migrations
pnpm db:migrate # apply migrations
pnpm db:studio # database GUI
# Dev servers
pnpm ui # dashboard only (localhost:5190)
pnpm server # API only (localhost:4301)
pnpm dev # planner + dispatcher + 4 workers
pnpm dev:full # add tester + docserDo not assume pnpm start, pnpm preview, pnpm migrate, or pnpm generate exist at root.
Execution loop: Planner → Dispatcher → Worker/Tester/Docser → Judge → Cycle Manager → (loop)
Monorepo layout:
apps/api— REST API + dashboard backend (Hono)apps/planner— task generation from requirements/issuesapps/dispatcher— queue lease schedulerapps/worker— execution engine (worker/tester/docser roles)apps/judge— PR review, approve/rework decisionsapps/cycle-manager— convergence, retry, cleanup loopsapps/dashboard— React UI (Vite)packages/core— domain primitives, failure codes, utilitiespackages/db— PostgreSQL schema (Drizzle ORM)packages/llm— LLM executor abstractionspackages/vcs— Git/GitHub operationspackages/queue— BullMQ queue abstractionspackages/policies— default recovery/auto-merge policiespackages/plugin-sdk— plugin platform contractplugins/tiger-research— reference plugin (planner-first research)
Stack: TypeScript, Node.js >=22.12, pnpm 9.x, Turbo, PostgreSQL, Redis/BullMQ, Vitest, oxlint/oxfmt.
Always use these exact terms when editing state or logic:
- Task status:
queued,running,done,failed,blocked,cancelled - Block reasons:
awaiting_judge,quota_wait,needs_rework,issue_linking - Task kinds:
code,research - Modes:
REPO_MODE(github/local-git/direct),JUDGE_MODE(github/local-git/direct/auto),EXECUTION_ENVIRONMENT(host/sandbox)
- Recovery-first: Convert failures into explicit next states. Never leave work in implicit halt.
- Backlog-first startup: Consume existing local/issue/PR backlog before generating new tasks. Planner starts only when
R && !I && !P && !L. - Idempotent control points: Preserve lease + runtime lock + run-claim semantics. Judge uses
judgedAt/judgementVersionto prevent double-review. - Ownership boundaries are strict: Planner plans, Dispatcher assigns, Worker executes, Judge evaluates, Cycle Manager converges. Do not move cross-layer orchestration into execution code.
- Plugin over hardcoding: Prefer plugin/registry extension over feature branching in core loops.
- State transitions must be atomic: update
status,blockReason, andupdatedAttogether. FollowfinalizeTaskStatepattern inapps/worker/src/worker-runner-state.ts. - Use
FAILURE_CODEconstants from@openTiger/corefor failure reasons. - Classify failures with
classifyFailure(errorMessage, errorMeta)— keep classifiers deterministic and side-effect free. - Retry count: always increment explicitly with
(task.retryCount ?? 0) + 1. - Repeated failure signatures must switch strategy (
needs_rework, autofix, or split rework), not retry forever. - Verification commands must be spawn-safe: no
$(), pipes,&&,||,;, redirections, or backticks in command definitions. - Emit structured events for transitions:
recordEvent({ type, entityType, entityId, payload }). - Use component-prefixed logs:
[Worker],[Judge],[Cleanup], etc.
- Framework: Vitest 3.x with
globals: true - Tests live in each app/package's
test/directory - For changed retry/classification/branching logic, add tests covering success path and guard/fallback path
- Run targeted tests for modified apps, then broader
pnpm testif changes cross packages
When changing any of these, update the corresponding docs in the same PR:
- State transitions or block reason semantics →
docs/state-model.md,docs/flow.md - Startup/replan gates →
docs/startup-patterns.md - Retry/recovery strategy →
docs/operations.md - Agent ownership →
docs/agent/*.md - API contracts →
docs/api-reference.md
- Explicit user prompt
- Nearest
AGENTS.mdin directory tree for file being edited - Root
AGENTS.md - Other repo docs (
README.md,docs/*,CONTRIBUTING.md)