fleet-pi
AGENTS.md9 starsChanged 7 months agoApache-2.0View on GitHub
Fleet Pi is a web workspace for the Pi coding agent: a TanStack Start app on Cloudflare Workers, a shadcn-style UI package, and a repo-local agent home in agent-workspace/. This file holds the rules agents must follow. Background and reference detail live in the linked docs. Start with docs/README.md, CONTEXT.md, and DESIGN.md. Run everything from the repository root with pnpm. Use pnpm --filter <workspace> <script> when only one package is affected. CI runs every backticked pnpm command in this file…
- 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 35,040 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 repositoryOne other file it gives its agents.
- agent-workspace/AGENTS.mdAGENTS.md
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
16 rules. About 0 are common, 3 are distinctive, and 13 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
13
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 11
Run everything from the repository root with pnpm.
- Very specific: line 63
Put new tests in a __tests__/ directory next to the code.
- Very specific: line 66
Never commit defaultProvider, defaultModel, or enabledModels in .pi/settings.json.
- Distinctive: line 70
When executing an attached plan, do not edit the plan file.
- Very specific: line 86
Keep security and isolation audit notes gitignored (.cursor/hooks/state/), never under tracked agent-workspace/artifacts/.
- Very specific: line 93
All UI lives in packages/hax-design.
- Very specific: line 99
No inline style props. Use Tailwind, cva, co-located CSS, or the semantic tokens in fleet-pi/styles/tokens.ts.
- Very specific: line 102
Prefer export-map hygiene over new shell or page-controller layers (for example FleetPiChatShell) until protocol types settle.
- Distinctive: line 121
Avoid generic AI SaaS looks (cream backgrounds, gradient heroes, card grids) and dense IDE toolbars unless asked.
- Very specific: line 188
Run pnpm chat:migrate after schema, ownership, or grant changes.
- Distinctive: line 212
Never block a chat stream on cold sandbox creation.
- Very specific: line 229
Keep each vendored extension's UPSTREAM.md current when refreshing it.
- Very specific: line 237
Keep CONTRIBUTING.md, SECURITY.md, CODE_OF_CONDUCT.md, and issue templates aligned with the real maintainer workflow.
- Very specific: line 245
Use autoctx capabilities to inspect supported commands and project state.
- Very specific: line 246
Use autoctx whoami to confirm provider credentials before running evaluations.
- Very specific: line 247
Run autoctx run from this directory to use the defaults stored in .autoctx.json.
≈ “Common” is an estimate: at least 1 in 5 of the 45,344 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
Fleet Pi is a web workspace for the Pi coding agent: a TanStack Start app on
Cloudflare Workers, a shadcn-style UI package, and a repo-local agent home in
agent-workspace/. This file holds the rules agents must follow. Background
and reference detail live in the linked docs. Start with docs/README.md,
CONTEXT.md, and DESIGN.md.
Commands
Run everything from the repository root with pnpm. Use
pnpm --filter <workspace> <script> when only one package is affected.
CI runs every backticked pnpm command in this file through
pnpm validate-agents-md, so only add commands that are safe to execute.
- Setup:
pnpm install. Devcontainer:.devcontainer/devcontainer.json(port3000, runspnpm installon create). - Daily:
pnpm typecheck,pnpm lint,pnpm test,pnpm build,pnpm e2e. - Format:
pnpm format(write) andpnpm format:check(CI gate). Both are Oxfmt through Vite+; import order and Tailwind class order are part of it. - Quality:
pnpm syncpack(fix drift withpnpm syncpack:fix),pnpm knip,pnpm jscpd,pnpm tech-debt,pnpm guard:no-eslint-prettier. - Docs:
pnpm generate:docsafter doc-generator sources change;pnpm generate:openapiafterpi-protocolschemas or route contracts change (pnpm generate:openapi -- --checkin CI);pnpm generate:openui-signaturesafter OpenUI component signatures change;pnpm validate-agents-mdafter editing this file. - Bundle size:
pnpm build --filter web, then openapps/web/bundle-report/stats.html. - Cloudflare:
pnpm build:cloudflarewhen Worker routing changes;pnpm verify-deployment-readinessbefore promotion. - Neon (needs credentials):
pnpm neon:deploy,pnpm neon:env-pull,pnpm neon:verify,pnpm auth:migrate,pnpm chat:migrate(needsFLEET_PI_CHAT_MIGRATION_DATABASE_URL).neon deployprovisions services only; run both migrations separately. - Data repair (owner URL; dry-run first,
--purgeonly after approval):pnpm quarantine-orphan-sessions,pnpm remap-auth-user-ids -- --file=remap.csv.
Deploy steps: docs/wiki/deployment.md and
docs/runbooks/deployment-release-gate.md.
Repository map
apps/web: TanStack Start app. Routes insrc/routes/;src/routeTree.gen.tsis generated, never edit it./api/chatissrc/routes/api/chat.ts.apps/web/src/lib/pi/: server-side Pi integration.runtime/holds the session factory, settings bridge, catalogs, and hot reload.durable/holds the hostedUserPiDurablepath.server.tsis the route-facing barrel.packages/hax-design: the only UI source (primitives,agent-elements/,components/openui/,components/fleet-pi/).packages/pi-protocol: browser-safe chat wire layer (types, Zod schemas,chat-types, provider catalog, OpenUI prompt). No React..pi/: Pi compatibility bridge (settings, skills, extensions, vendored extensions withUPSTREAM.md).agent-workspace/: the agent's durable home (skills, memory, plans, evals, artifacts). Seedocs/agent-workspace.md.
General rules
- One lockfile: root
pnpm-lock.yaml. Never create nested lockfiles. - Put new tests in a
__tests__/directory next to the code. Write E2E artifacts to PlaywrighttestInfo.outputPath(), never machine paths. AGENTS.mdis the only agent instruction file; do not recreateCLAUDE.md.- Never commit
defaultProvider,defaultModel, orenabledModelsin.pi/settings.json. Users choose models in Settings. The file stays gitignored, andapps/web/src/lib/pi/__tests__/resource-expectations.test.tsfails if it is ever tracked again. - When executing an attached plan, do not edit the plan file; finish its todos.
- The pre-commit hook (Husky + lint-staged) runs
vp fmtandvp lint --fixon staged files inapps,packages, and.pi/extensions.git config core.hooksPathmust point at.husky. Fix lint errors; do not bypass the hook. - Oxfmt and Oxlint are configured only in the
fmtandlintblocks of the rootvite.config.ts. Never add.prettierrc,.prettierignore, or aneslint.config.*;pnpm guard:no-eslint-prettierfails CI'slintjob if they reappear, and.syncpackrcbans the packages themselves. - Naming is review policy, not a lint rule:
camelCasefor variables, functions, and object keys;PascalCasefor types and components (and for component-shaped functions or factory results such asconst Badge = ...);SCREAMING_SNAKE_CASEonly for true module constants. Prefix booleans withis/has/should/canwhere the name would otherwise be ambiguous. Use_only for a deliberately unused parameter; that case is exempt fromno-underscore-dangle. - Keep security and isolation audit notes gitignored (
.cursor/hooks/state/), never under trackedagent-workspace/artifacts/.
UI rules
Design context: DESIGN.md, PRODUCT.md, packages/hax-design/ARCHITECTURE.md.
- All UI lives in
packages/hax-design; routes only compose its exports. Never add components underapps/web/src/components/. Add registry components withpnpm dlx shadcn@latest add <name> -c packages/hax-design. - Inside hax-design use relative imports; apps import
@workspace/hax-design/*. - OpenUI library and registry code lives in
components/openui/. Deepen it instead of adopting@openuidev/react-uiunless asked. - No inline
styleprops. Use Tailwind,cva, co-located CSS, or the semantic tokens infleet-pi/styles/tokens.ts. Preferfleet-pi/primitives/(ItemRowvariants) over nested cards or repeated class strings. - Prefer export-map hygiene over new shell or page-controller layers (for
example
FleetPiChatShell) until protocol types settle. - Header chrome stays floating pills (
bg-sidebarwhen inactive,rounded-full). Panel tabs useTabsSubtle(Active Label and pill variants) inline when panels are open, and the header stacks above the content row (CHAT_HEADER_LAYER_CLASS). - The chat column is one transcript plus the InputBar. The right panel holds
Workspace, Pi Resources, and Artifacts only, all scoped to
agent-workspace/. Settings (providers, models, skills, appearance, sandbox) live in the Settings dialog. - The Settings dialog follows shadcn sidebar-13: icon+label nav, flat
ItemRowlists, an inline drill-down for Add provider (no nested Dialogs), and auto-save viaPATCH /api/chat/settings. - Slash suggestions come from
/api/chat/commands, scroll, and are arrow-key navigable. Pi builtins open UI (/modelopens the picker;/models,/settings,/configopen Settings); skill and prompt commands go to the agent. - Settings › Providers lists only configured providers. LLM Models curates models discovered from them, grouped by provider with an All/Enabled filter.
- Avoid generic AI SaaS looks (cream backgrounds, gradient heroes, card grids) and dense IDE toolbars unless asked.
Chat runtime
Reference: docs/wiki/apps/web/pi-integration.md,
docs/wiki/apps/web/plan-mode.md, docs/wiki/api/endpoints.md.
- Protocol types come from
@workspace/pi-protocol(UI message types from@workspace/pi-protocol/chat-types). Server code never importsagent-elementsoropenuicomponents. handleChatTurn(apps/web/src/lib/pi/handle-chat-turn.ts) owns turn logic. The/api/chatroute only authenticates, parses, and pipes NDJSON.- Local and legacy sessions are Pi JSONL files. An invalid, outside, or
missing session file starts a fresh project-scoped session; never surface an
error. Hosted Agent sessions use
durable:ids, and their transcript is the Durable Object. - File tools and bash cwd stay inside the active project or workspace root.
- Modes: Agent has the coding tools plus approved external tools. Plan is
read-only: never give it mutating, file-change, subagent, or
fetch_contenttools. Harness allows evaluation writes. Allowlists live inplan-mode.ts. - Model choices come from Pi
ModelRegistry/SettingsManager, never a hard-coded UI list.enabledModels: []means deny-all.
Hosted deployment (Cloudflare)
Reference: docs/wiki/deployment.md, docs/adr/0004-user-controlled-transcript-deletion.md.
- Hosted transcripts live in each user's
UserPiDurableDurable Object. Neon holds auth, settings, and an optional projection that must never fail a hosted turn. The Daytona volume holds harness files and artifacts. Do not add an R2 binding. Neon Object Storage is limited to the privatefleet-pi-spikeproof bucket inneon.ts(preview.buckets) — not for transcripts oragent-workspace. Productizing more buckets needs an ADR. DELETE /api/chat/accounterases the Durable Object as well as Neon rows. Deleting one hosted session is only a tombstone (Pi Durable has no per-conversation delete).- Without a Daytona key, hosted turns use the Durable Object workspace store
(
durable/do-workspace-store.ts): allowlisted text files, no shell. It syncs to the volume on the first sandbox turn and never overwrites a file that differs there (.fleet/do-import/instead). - Worker code must not import from
.pi/; colocate helpers underapps/web/src/lib/pi/. Existing exceptions are tracked inagent-workspace/memory/project/known-issues.md. - Per-user Pi settings persist in Neon
pi_user_settings;.pi/settings.jsonis not writable on Workers. Fleet base defaults merge from code (fleet-default-project-settings.ts) and ship no provider or model. Settings paths must be portable (no/Users/…). - Org LLM keys (
GEMINI_API_KEY,OPENROUTER_API_KEY, …) never back chat on Workers. They are scrubbed from the process. Chat uses signed-in user BYOK or the platform Neon AI Gateway.
Auth and data isolation
Reference: docs/wiki/security.md, docs/runbooks/deployment-release-gate.md.
- Deploys use Neon Managed Auth (
NEON_AUTH_BASE_URL/VITE_NEON_AUTH_URL). Local anonymous or SQLite Better Auth applies only when neither is set.BETTER_AUTH_SECRETis still required for BYOK encryption. - Session-scoped chat and workspace APIs require auth on Workers through
withAuthenticatedChatRequest.auth-mode.tsstays client-safe; server auth lives inchat-api-auth.ts. - Runtime
FLEET_PI_CHAT_DATABASE_URLmust be the non-ownerfleet_pi_approle.pi_*tables keepFORCE ROW LEVEL SECURITY. Mirror ownership probes fail closed. - Neon Data API stays off (
dataApi: false). Never grantauthenticatedoranonymousonpi_*, and never exposeneon_auth.*. - Run
pnpm chat:migrateafter schema, ownership, or grant changes.
Providers and models
Reference: docs/wiki/apps/web/pi-integration.md.
- Provider ids live in
packages/pi-protocol/src/provider-catalog.ts. The Google id isgoogle(GEMINI_API_KEY);GOOGLE_CLIENT_*are OAuth only. - The composer picker lists only models the user added. The full catalog is
Settings-only (
scope=all). - OpenAI Chat Completions (
openai-chat-completions) registers only the configured model id, never a remote/modelscatalog. Without OCC BYOK, authenticated deploys back it with Neon AI Gateway (max_tokens≤ 25,000). - Custom providers register as native Pi providers (
custom+<slug>) and reusepi_user_providers; there is no migration.
Daytona
Reference: docs/daytona.md.
- On Workers, sandboxes use only each user's BYOK Daytona key. Org keys and
DAYTONA_API_KEYnever back user sandboxes (local dev may use them). - Volume
fleet-pi-ws-{userId}mounts only at/home/daytona/agent-workspace. Seeding never overwrites user files. - Never block a chat stream on cold sandbox creation; use the cached sandbox or a background warm-up.
- The web adapter is
.pi/extensions/daytona-sandbox.ts. Stocknpm:@daytona/piis CLI-only; never list it in.pi/settings.json.
agent-workspace and memory
- Durable project memory lives in
agent-workspace/memory/project/{architecture,decisions,preferences,open-questions,known-issues}.md. "Remember this" updates the narrowest file; do not create ad hoc memory files. apps/web/src/lib/workspace/server.tsowns the layout. Seeding creates missing Markdown stubs and never overwrites existing files.- Chat-driven Pi resource installs use
resource_installand land underagent-workspace/pi/{skills,prompts,extensions,packages}. Skills and prompts apply after reload. Extensions and packages stay staged unless the user asks to activate them. "Plugins" means Pi resource packages, not Codex or Claude plugin bundles. - Keep each vendored extension's
UPSTREAM.mdcurrent when refreshing it.
Docs upkeep
README.mdis the public landing page; keep it short.docs/README.mdis the docs hub, anddocs/quickstart.mdis onboarding.docs/api.md,docs/architecture.md, anddocs/project-structure.mdare generated. Fix the generator or its sources, never the output.- Keep
CONTRIBUTING.md,SECURITY.md,CODE_OF_CONDUCT.md, and issue templates aligned with the real maintainer workflow. - Manual chat checks before release:
docs/wiki/how-to-contribute/testing.md.
<!-- AUTOCTX_GUIDE_START -->AutoContext
- Use
autoctx capabilitiesto inspect supported commands and project state. - Use
autoctx whoamito confirm provider credentials before running evaluations. - Run
autoctx runfrom this directory to use the defaults stored in.autoctx.json.
<!-- AUTOCTX_GUIDE_END -->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.

