maskin
AGENTS.md8 starsChanged 3 months agoApache-2.0View on GitHub
This file provides guidance to Codex (Codex.ai/code) when working with code in this repository. If the user asks how to start this repo, start it, set it up, or similar — follow this flow exactly. The goal is to get them from clone → running workspace → MCP-connected → get_started in as few steps as possible, inside a SINGLE Codex session. Do NOT guess commands or URLs; read the dev server's own banner output. Don't skip steps 2 or 5.…
- Reads credentials
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 31,439 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository7 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- add-shadcn-componentSkill
- frontend-taskSkill
- workspace-observer-onboardingSkill
- add-shadcn-componentSkill
- frontend-taskSkill
- maskin-designSkill
The file
We split this AGENTS.md into the rules it gives an agent
6 rules. About 0 are common, 1 is distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 17
Don't skip steps 2 or 5. The API key and workspace id only exist after the dev server boots and the auto-bootstrap runs.
- Very specific: line 77
All validation via Zod schemas in packages/shared/src/schemas/
- Very specific: line 81
All write endpoints accept Idempotency-Key header
- Very specific: line 87
All external inputs validated at system boundaries — see .Codex/rules/input-validation.md for specifics
- Distinctive: line 179
Test pyramid for frontend: lib utilities → hooks → components
- Very specific: line 193
Important: All env vars used at runtime must be listed in turbo.json globalPassThroughEnv.
≈ “Common” is an estimate: at least 1 in 5 of the 40,246 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AGENTS.md
This file provides guidance to Codex (Codex.ai/code) when working with code in this repository.
Onboarding a new user from Codex
If the user asks how to start this repo, start it, set it up, or similar — follow this flow exactly. The goal is to get them from clone → running workspace → MCP-connected → get_started in as few steps as possible, inside a SINGLE Codex session. Do NOT guess commands or URLs; read the dev server's own banner output.
- Install deps + start the stack. Run
pnpm install, then start the dev stack in the background withpnpm dev:winon Windows orpnpm devon macOS/Linux. Use a background shell so the logs keep streaming. The dev script auto-seeds missingINTEGRATION_ENCRYPTION_KEYandDATABASE_URLin.env— do NOT write or overwrite those yourself. - Wait for the startup banner. Poll the shell output (BashOutput / similar) until you see the
🚀 Maskin is runningbanner printed byapps/dev. It appears afterPG NOTIFY bridge startedand the S3/container init lines. Don't tell the user anything is ready before you see this banner. - Extract the ready-made MCP command from the banner. The banner prints a copy-pasteable
Codex mcp add maskin -e API_BASE_URL=... -e API_KEY=ank_... -e WORKSPACE_ID=... -- pnpm --filter @maskin/mcp startline with real credentials (the dev bootstrap auto-provisions adev@localactor +My Workspaceon a fresh DB, or looks up an existing actor if the DB already has one). Parse that exact line from the log output — do NOT reconstruct it by hand. - Run that exact
Codex mcp addcommand for the user so the MCP server gets wired into Codex. - Reload plugins to pick up the new MCP server in this session by running
/reload-plugins. This is critical — it makes the Maskin MCP tools (includingget_started) available immediately without closing and reopening Codex. - Call
get_startedwith no args to see the loop menu. Do NOT wait for the user to paste a starter prompt. Call theget_startedMCP tool with no arguments (or justworkspace_id). It returns a numbered list of marketplace loops with ids and descriptions. Read that list back to the user and ask (a) which loop they want to install and (b) whether they want to rename the workspace. Then callget_startedagain with{ loop_id: "<id from the list>", confirm: true, workspace_name: "<name if they want to rename, else omit>" }to install. - Relay the "Connect your Claude subscription" prompt. When
get_startedinstalls a loop, its response includes a block directing the user to<frontendUrl>/<workspaceId>/settings/keysto import their Claude Pro/Max credentials — agent sessions cannot run without them. Render that prompt as written and wait for the user to confirm before kicking off the pipeline.
Don't skip steps 2 or 5. The API key and workspace id only exist after the dev server boots and the auto-bootstrap runs; and without /reload-plugins the MCP tools won't be callable in the current session.
Sub-project AGENTS.md
apps/web/AGENTS.md— detailed frontend guidance: product philosophy, design system, component conventions, routing, state management, SSE patterns, and styling rules
Project Rules
.Codex/rules/frontend.md— frontend component reuse, DRY, and consistency rules (shadcn/ui, Radix UI).Codex/rules/testing.md— testing conventions for all test types (unit, integration, E2E, frontend).Codex/rules/pre-commit.md— pre-commit checklist (lint, type-check, tests).Codex/rules/pr-merge.md— PR merge checklist (up to date with main, lint, type-check, tests).Codex/rules/input-validation.md— input validation requirements at system boundaries (HTTP params, env vars, DB triggers).Codex/rules/structural-verification.md— file placement and build configuration verification checklist.Codex/rules/known-pitfalls.md— registry of recurring bugs to check against before submitting codepackages/db/MIGRATIONS.md— migration conventions for hot tables (CONCURRENTLY indexes, chunked backfills); read before editing a.sqlfile produced bypnpm db:generate
Reference
docs/reference/README.md— Canonical documentation for Maskin's primitives — read the matching page before trusting model memory.
Architecture
- Modular monorepo managed by Turborepo + pnpm workspaces:
apps/(deployable services) +packages/(shared libs) - Backend (
apps/dev): Hono.js + OpenAPIHono + Drizzle ORM + PostgreSQL, runs on port 3000 - Frontend (
apps/web): Vite + React 19 + TanStack Router + TanStack Query + Tailwind CSS 4, runs on port 5173, proxies/apito backend - Auth: API keys (plain text,
ank_prefix). Bearer token in Authorization header.authMiddlewareinpackages/authalso enforces workspace membership whenX-Workspace-Idis present — header-based routes don't need their ownisWorkspaceMember()check; only by-ID routes (where the workspace is derived from the resource) do. - Real-time: PG NOTIFY → SSE bridge (packages/realtime) — events table has a DB trigger that fires NOTIFY on insert
- Agent execution: Docker-based container sessions in
apps/dev/src/services/session-manager.ts— spins up ephemeral containers running Codex, Codex, or custom CLIs. Persistent agent files (skills, learnings, memory) stored in S3-compatible storage (SeaweedFS for dev). Sessions are trackable, streamable via SSE, pausable/resumable via snapshots. - Container management:
apps/dev/src/services/container-manager.tswraps dockerode - Agent file storage:
packages/storageprovides abstractStorageProviderinterface with S3 implementation (@aws-sdk/client-s3).apps/dev/src/services/agent-storage.tsmanages pull/push of agent files. - MCP server:
packages/mcpwraps the API as 73 tools for external agents (stdio + HTTP transport) - Workspace context passed via
X-Workspace-Idheader on all workspace-scoped routes
Prerequisites
- Node.js ≥ 20
- pnpm 9.15.0
- Docker + Docker Compose (must be installed and running —
pnpm dev/pnpm dev:winstart PostgreSQL + SeaweedFS viadocker-compose, the app cannot run without it)
Commands
pnpm install— install all dependenciespnpm dev— start Docker (postgres + seaweedfs), run migrations, then start all services via Turborepopnpm dev:win— same as above but for cmd/PowerShell on Windows (uses Node script instead of bash)pnpm build— build all packagespnpm --filter=@maskin/mcp build— build a specific package (filter goes BEFOREbuild)pnpm --filter=@maskin/web build— build web app onlypnpm test— run all tests (Vitest)pnpm test -- --filter=@maskin/dev— run tests for a specific packagecd apps/dev && pnpm vitest run src/__tests__/auth.test.ts— run a single test filepnpm test:integration— run integration tests (requires real database)pnpm type-check— TypeScript type checking across all packagespnpm lint— lint with Biome (biome check .)pnpm lint:fix— auto-fix lint issuespnpm format— format with Biome- A pre-commit hook (
.githooks/pre-commit, installed bypnpm install) runs the Biome auto-fix on staged files; skip it withgit commit --no-verifyorSKIP_BIOME_HOOK=1 docker-compose up postgres -d— start PostgreSQL only (not needed if usingpnpm dev)docker-compose up— start PostgreSQL + all servicespnpm db:generate— generate Drizzle migration from schema changespnpm db:migrate— run Drizzle migrations (automatically run bypnpm dev)pnpm db:seed— seed demo data
Code Conventions
- Biome for linting + formatting (not ESLint/Prettier) — ignores
node_modules,dist,drizzle,.turbo - Tab indentation, single quotes, semicolons as-needed, 100 char line width
- All validation via Zod schemas in
packages/shared/src/schemas/ - Drizzle for all DB access — SQL-like API, no magic
- Route files export a Hono app, mounted in
apps/dev/src/index.ts - Events logged on every mutation (create/update/delete) for audit + real-time
- All write endpoints accept
Idempotency-Keyheader - Frontend uses
@path alias mapped to/srcinapps/web - Frontend routing: file-based with TanStack Router (
apps/web/src/routes/),routeTree.gen.tsis auto-generated - Frontend data fetching: TanStack Query hooks in
apps/web/src/hooks/, API client inapps/web/src/lib/api.ts - Frontend SSE: real-time cache invalidation via
apps/web/src/lib/sse-invalidation.ts - UI components: Radix UI primitives + custom components in
apps/web/src/components/ui/ - All external inputs validated at system boundaries — see
.Codex/rules/input-validation.mdfor specifics - PG NOTIFY payloads must stay under 8KB — truncate large fields in DB triggers
Data Model
- Unified
objectstable withtypefield: 'insight' | 'bet' | 'task' actorstable: humans and agents share the same identity modelworkspaceswith configurable settings (statuses, field definitions, display names)workspace_members— joins actors to workspaces with roleseventstable = audit log + real-time feed (PG NOTIFY trigger)relationships= universal edge table between objects (unique on source_id + target_id + type)triggers= cron or event-based automation, fires agents via container sessionssessions= container execution sessions, tracks lifecycle (pending → running → completed/paused/failed/timeout)session_logs= append-only log output from container sessions (stdout/stderr/system), used for SSE streamingagent_files= metadata index for agent files stored in S3 (skills, learnings, memory)
API Routes
Public (no auth)
GET /api/health— health checkGET /api/openapi.json— OpenAPI specPOST /api/actors— signup, returns API key (agents: caller API key + workspace_id, born as a member)
Actors (/api/actors)
GET /api/actors— list actorsGET /api/actors/:id— get actor by IDPATCH /api/actors/:id— update actorPOST /api/actors/:id/api-keys— regenerate API key
Objects (/api/objects) — unified CRUD for insight/bet/task
POST /api/objects— create objectGET /api/objects— list objects (filter by type, status, owner)GET /api/objects/search— search objects by text in title/contentGET /api/objects/:id— get object by IDGET /api/objects/:id/graph— get object with all relationships and connected objectsPATCH /api/objects/:id— update objectDELETE /api/objects/:id— delete object
Workspaces (/api/workspaces)
POST /api/workspaces— create workspaceGET /api/workspaces— list workspaces for current actorPATCH /api/workspaces/:id— update workspacePOST /api/workspaces/:id/members— add memberGET /api/workspaces/:id/members— list members
Relationships (/api/relationships)
POST /api/relationships— create relationshipGET /api/relationships— list relationships (filter by source_id, target_id, type)DELETE /api/relationships/:id— delete relationship
Triggers (/api/triggers)
POST /api/triggers— create triggerGET /api/triggers— list triggersPATCH /api/triggers/:id— update triggerDELETE /api/triggers/:id— delete trigger
Events (/api/events)
GET /api/events— SSE stream (supports Last-Event-ID)GET /api/events/history— paginated event history
Sessions (/api/sessions) — container-based agent execution
POST /api/sessions— create sessionGET /api/sessions— list sessionsGET /api/sessions/:id— get session detailsPOST /api/sessions/:id/stop— stop sessionPOST /api/sessions/:id/pause— pause & snapshot sessionPOST /api/sessions/:id/resume— resume paused sessionGET /api/sessions/:id/logs— paginated log historyGET /api/sessions/:id/logs/stream— SSE stream of live logs
Graph (/api/graph) — batch operations
POST /api/graph— atomic batch create (objects + relationships in one transaction)
Integrations (/api/integrations)
GET /api/integrations— list integrations for workspaceGET /api/integrations/providers— list available providersPOST /api/integrations/:provider/connect— start OAuth/connection flowGET /api/integrations/:provider/callback— OAuth callback (no auth)DELETE /api/integrations/:id— disconnect integration
Webhooks (/api/webhooks) — no auth
POST /api/webhooks/:provider— incoming webhook handler
MCP HTTP Transport
POST /mcp— Streamable HTTP transport for MCP Apps
Testing
- Full conventions: see
.Codex/rules/testing.mdfor patterns, file locations, and examples - Pre-commit: see
.Codex/rules/pre-commit.md— always run lint, type-check, and tests before committing - Backend unit tests: Vitest with mock DB context (
apps/dev/src/__tests__/setup.ts) - Backend integration tests: Vitest with real PostgreSQL (
apps/dev/src/__tests__/integration/) - Frontend tests: Vitest + React Testing Library + jsdom (
apps/web/src/__tests__/) - E2E tests: Playwright (
apps/e2e/src/tests/) - Test pyramid for frontend: lib utilities → hooks → components
pnpm test -- --run— run all unit testspnpm test:integration -- --run— run integration tests (requires DATABASE_URL)pnpm test:e2e— run E2E tests (requires running dev server)
Environment Variables
DATABASE_URL— PostgreSQL connection string (required)PORT— server port (default 3000)S3_ENDPOINT— S3-compatible storage endpoint (default:http://localhost:8333for SeaweedFS)S3_BUCKET— storage bucket name (default:agent-files)S3_ACCESS_KEY,S3_SECRET_KEY— S3 credentials (default:admin/adminfor dev)S3_REGION— S3 region (default:us-east-1)CORS_ORIGIN— comma-separated allowed origins for CORS (default:http://localhost:5173)
Important: All env vars used at runtime must be listed in turbo.json globalPassThroughEnv. Turbo filters env vars — unlisted ones are silently unavailable to dev/build tasks. When adding new env vars (e.g., for integrations), always add them there too.
Principles
- Simple & intuitive
- Speed — blazingly fast
- Everything's an API
- Transparent — live feedback on everything
- Agents-first — agents run autonomously
- Idempotency — all write endpoints accept Idempotency-Key
- Observability — structured logging from day one
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

