fastagent
AGENTS.md67 starsChanged 6 days agoMITView on GitHub
FastAgent turns a file-defined agent (SYSTEM.md, AGENTS.md, skills/, code under src/) into a live service: in an app or over HTTP, all through one API of its own, the Agent API. Chat platforms reach an agent through that API from outside the runtime: channels are not part of it. - What FastAgent does is what packages/*/src/ does. Nothing else describes the implementation. A file's header says what the file owns and why it is that way, next to the code…
- Reads credentials
- Commits and pushes
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 33,398 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.
- llms.txtllms.txt
The file
We split this AGENTS.md into the rules it gives an agent
11 rules. About 0 are common, 1 is distinctive, and 10 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.
10
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Very specific: line 20
When a doc and the code disagree, the code is right.
- Distinctive: line 22
Do not commit design notes, plans, measurements or progress logs.
- Very specific: line 63
Pure functional core, Effect v4 boundaries: Keep domain transforms, config validation, secret grouping, and deploy artifact generation as …
- Very specific: line 71
Read node_modules/effect/AGENTS.md and node_modules/effect/src/ before using an API.
- Very specific: line 78
A convention with four enforcers has none: When several call sites must each remember a thing, put it in one function they all call, and …
- Very specific: line 113
Append before creating: When adding fewer than ~8 tests in an existing domain, append to that domain's test file instead of opening a new …
- Very specific: line 114
Canonical seams only: Use runInProcess for CLI tests (never spy on process.cwd/console.log), git-double.ts, tsc-double.ts, …
- Very specific: line 115
Hermetic isolation (
test/setup.ts,test/unit-setup.ts): Every file gets an empty HOME, stripped proxy env vars, non-loopback network … - Very specific: line 116
Deterministic Effect & property tests: Prefer @effect/vitest (it.effect with TestClock from effect/testing) for TTL, keep-alive, …
- Very specific: line 137
Never commit to main. Use a branch prefix (feature/, fix/, refactor/, docs/, chore/, ci/, test/), then gh pr create --base main --assignee …
- Very specific: line 140
After opening a PR, report it with the local gate result and stop.
≈ “Common” is an estimate: at least 1 in 5 of the 43,423 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
fastagent — Agent Guide
FastAgent turns a file-defined agent (SYSTEM.md, AGENTS.md, skills/, code under src/) into a live service: in
an app or over HTTP, all through one API of its own, the Agent API. Chat platforms reach an agent through
that API from outside the runtime: channels are not part of it.
The code is the only source of truth
- What FastAgent does is what
packages/*/src/does. Nothing else describes the implementation. A file's header says what the file owns and why it is that way, next to the code the reason is about. Read the code and its headers. Start frompackages/fastagent/src/index.ts(the package),packages/client/src/agent-api.ts(the Agent API),packages/client/src/http/contract.ts(the API over HTTP) andpackages/fastagent/src/cli/program.ts(the CLI). - The packages. An npm workspace, one version for all, each with an isolated dependency tree:
@fastagent-sh/client(the cloud-agnostic Agent API and zero-Node-depconnectAgent/connectAuthHTTP client; it imports no runtime or cloud SDK),@fastagent-sh/client-agentcore(zero-Node-dep Amazon Bedrock AgentCore SigV4 client wrappingconnectAgent),@fastagent-sh/fastagent(the cloud runtime, PostgreSQL single-writer lease kit,HarnessProviderSDK, and CLI),@fastagent-sh/agentcore(pure Amazon Bedrock AgentCore MicroVM server adapter overopenAgentand PostgreSQL; zero AWS SDK or CDK deps), and@fastagent-sh/harness-dsh(optional second server-grade runtime harness backed by@deepseek-ai/dshwith native OS sandboxing; loaded lazily by@fastagent-sh/fastagentso core carries zero@deepseek-ai/*dependencies). A package reaches another only by name, and in the repository reads its source through the@fastagent-sh/sourceexport condition;test/guards/package-boundary.test.tsholds the lines. docs/is for users and developers: product positioning (docs/overview.md), technical architecture (docs/architecture.md), authoring, configuration, remote operations (docs/remotes.md), embedding, deployment, and the Agent API contract (docs/agent-api.md). Docs stay user- and developer-facing and never include process logs or design history.- When a doc and the code disagree, the code is right. Fix the doc or delete the passage. A change in what a user does
or sees updates its guide in the same PR. A CLI command's flags are its
--help, generated frompackages/fastagent/src/cli/program.ts. - Do not commit design notes, plans, measurements or progress logs. They go in the PR description. Anything that stays true goes into the code: a name, a header, a test.
- The Agent API is
packages/client/src/agent-api.tsandpackages/client/src/http/contract.ts; what it promises isdocs/agent-api.md, andtest/harnesses/agent-api-conformance.tsandtest/unit/agent-api/http-api.test.tsenforce those promises across bothpi-durableanddshharnesses. Changing them is an explicit decision.
Product matrix boundaries
FastAgent is the open-source cloud runtime narrow waist inside a four-part orthogonal product matrix. Keep each concern in its owning repository:
fastagent(this repository): Cloud-deployed runtime kernel, immutable agent artifact build (fastagent build), server-gradeHarnessProviderplugins (pi-durable,dsh), SQLite/PostgreSQL single-writer fenced state, and the canonicalAgent API(@fastagent-sh/client). Targets cloud-embedded backends (openAgent/service.fetch) and scale-to-zero containers. Never add local desktop/IDE runtime modes, editorACPstdio wrappers, third-party SaaS OAuth vaults, or managed cloud billing here.duang: External capability catalog, progressive 4-meta-tool discovery (discover,inspect,call,get_call), and per-team encrypted credential vault exposed to agents via standard remote HTTP/mcpandSKILL.md.fastagent-cloud: Managed serverless hosting, scale-to-zero compute/sandbox pools, visitor sharing boundaries, and billing for compiledfastagentartifacts over the standardAgent API.kage: Cross-platform thin client (Web, macOS, mobile) speaking@fastagent-sh/clientAgent APIto cloud-deployedfastagentinstances; owns zero agent runtime or second session store.
Decisions the code cannot show
- Two harnesses behind one contract.
pi-durableis the built-in default harness and@fastagent-sh/harness-dshis an optional second harness with native OS sandboxing. The contract boundary stays strictly at@fastagent-sh/client's Agent API +test/harnesses/agent-api-conformance.ts(no internalLoopPort).@earendil-works/pi-*is imported only underpackages/fastagent/src/harnesses/. Every agent definition (AGENTS.md,SYSTEM.md,skills/,.mcp.json, andsrc/tools/viadefineToolor Standard JSON Schema v1 tool objects) is 100% portable across both harnesses. - The contracts import no harness. The client's
agent-api.tsimports onlyeffect/Schema; the runtime'smcp-api.tsimports nothing. Each package'ssrc/index.tsnames every export and exports no assembly part (openServing,serveAgent,openDurableAgentstay internal).test/guards/package-boundary.test.tschecks this. - One process owns an instance's state. That state is the instance's storage (its SQLite file, or its rows in the
PostgreSQL database
FASTAGENT_DATABASE_URLnames) and each Caller's files under the state root. A deployment routes every session of one storage to one process. What a Caller reads back is durable before it is reported. - The artifact carries the agent; the machine lends it an environment. Prompt files,
AGENTS.md,src/andskills/come from the bundle, never from the machine (no skill or prompt from~/.pi/agent). The box supplies only commands and variables, the waybashinheritsPATH. - A session id belongs to the Agent; a conversation id belongs to the Caller. A tool that asks which session it runs in gets the id the Agent handed out
(
sessionIdOf). - The CLI serves a person and a coding agent alike. Nothing waits on a terminal. A choice not given exits 2 and
names what to pass. A step only a person can take returns at once (
need_user_action, a check command), and a process of the CLI's own finishes it. A secret is never typed into the agent's conversation. Results go to stdout, everything else to stderr. A command whose result is data has--json.
Engineering rules
- Fail visibly. A message that cannot be answered ends
failed, and itserrorsays why. A refused operation rejects with anAgentError. A stream is refused on its first read. Once it has delivered anything, a failure ends it with astream_errorevent, never a rejection. - Pure functional core, Effect v4 boundaries. Keep domain transforms, config validation, secret grouping, and
deploy artifact generation as plain synchronous pure functions over
readonlyinputs usingES2025non-mutating APIs (Map.groupBy,toSorted,Set,Iterator) — never wrap trivial synchronous calculations inEffect. Isolate I/O, lifecycles (Scope,Deferred,Ref,Effect.acquireRelease), operation spans (Effect.fn), time (Clock), secrets (Redacted<string>), and env decoding (packages/fastagent/src/process-env.tsConfig) in Effect v4. Keep public SDK and runtime entrypoints (@fastagent-sh/client,openAgent,serveAgent) returning standardPromise/AsyncIterableand accepting plainstringinputs while enforcingSchema.branddomain IDs (SessionId,ConversationId,ConversationKey,MessageId,IdempotencyKey) andRedacted<string>internally. Readnode_modules/effect/AGENTS.mdandnode_modules/effect/src/before using an API; never edit it or import from inside it.npm run typecheckruns@effect/tsgowithfloatingEffect: "error". - A finalizer does not fail. Since effect 4.0.6, a defect in a combined cause turns every typed failure into a defect, so a finalizer that dies hides the body's failure. A finalizer logs its own failure, or leaves it to an explicit call in the body.
- The run plane and the observation plane read the same state through the same function. What will execute and what is reported must not be derived separately.
- A convention with four enforcers has none. When several call sites must each remember a thing, put it in one
function they all call, and make that function repair rather than trust (
writeFileAtomic).
Tests
What the suite tests: user-visible contracts and high-risk invariants, never wiring. A test proves either a contract a user or host relies on (through the entry they call: Agent API, CLI command, package export, generated files) or a pure/concurrency invariant whose failure silently corrupts state or security. Each contract gets one test for its main case, one for each promised refusal, and one for each security boundary. Never test internal call order, private helpers, or non-actionable wording.
See test/README.md for the double inventory and suite index.
Tiers are set by the resources a test uses. Pick the smallest tier that can prove the behavior:
| Layer / Tier | Files, command | Scope & allowed resources | Timeout |
| Guards (L0) | test/guards/*.test.ts, npm run test:guards | Static export/dependency boundaries, double parity, command coverage, and hygiene rules | 20 s |
| Unit (L1) | test/unit/<domain>/*.test.ts, npm test | Pure invariants (no I/O) and contract specs via standard doubles, temp dirs, SQLite, loopback sockets, fake timers. No child processes. | 20 s |
| Integration (L2) | test/integration/**/*.integration.test.ts, npm run test:integration | Double parity checks, cross-process locks/signals/pipes, real build/tsc/git/MCP subprocesses, npm pack | 30 s |
| Artifact smoke (L3) | CI only: test/smoke/e2e/packed.ts | Installed tarball without src/ aliases | the job |
Change-to-Test Matrix:
| Change area | Required tests | Mandatory seam (do not invent a local mock) |
Agent API / HTTP (packages/client/src/agent-api.ts, src/http/ in both packages) | test/harnesses/agent-api-conformance.ts, test/unit/agent-api/http-api.test.ts | durableSubject / httpSubject |
CLI command or flag (packages/fastagent/src/cli/) | test/unit/cli/: main path, exit 2/1 refusals, --json shape | runInProcess (test/doubles/cli-run.ts) |
Deploy (packages/fastagent/src/deploy/) | test/unit/deploy/: preflight gates, generated artifacts | No secrets in artifacts |
| Security boundary | test/unit/security/: valid pass + explicit refusal naming the error | Mutation check: break the guard and watch the new test fail before keeping it |
Test double (test/doubles/*-double.ts, cli-run.ts) | Update its test/integration/double-parity/*.integration.test.ts parity test | Same inputs against the double and the real tool must match |
| Bugfix | Minimal regression test reproducing the bug | L1 preferred; use L2 only when process/lock/tool behavior is essential |
How the suite stays fast and consistent:
- Scoped local loop: Iterate on the domain you touched (
npx vitest run test/unit/<domain>/andnpm run test:guards), then run the full local loop before pushing. - Append before creating: When adding fewer than ~8 tests in an existing domain, append to that domain's test file instead of opening a new
.test.tsfile (each file inpool: "forks"pays a cold-import cost). - Canonical seams only: Use
runInProcessfor CLI tests (never spy onprocess.cwd/console.log),git-double.ts,tsc-double.ts,storage-no-wait.ts, andscripted-agent.ts. - Hermetic isolation (
test/setup.ts,test/unit-setup.ts): Every file gets an emptyHOME, stripped proxy env vars, non-loopback network refusal (inherited by Node children viaNODE_OPTIONS), and child-process refusal in unit tests. Unit tests run shuffled (--sequence.seed=<n>repeats an order). - Deterministic Effect & property tests: Prefer
@effect/vitest(it.effectwithTestClockfromeffect/testing) for TTL, keep-alive, retry/backoff, and scoped lifecycle tests, andit.prop/it.effect.prop(effect/Arbitrary) for Schema codec round-trips and state invariants. - Hygiene guards (
test/guards/suite-hygiene.test.ts): Bare.toThrow(), elapsed-time upper bounds, shared temp parent paths (join(dir, "..", name)instead ofbesideAgent(dir, name)), ghost file references, missing double parity, missing CLI command tests, CLI seam bypasses, unauthorizedprocess.envaccess outside approved boundary files, and silent emptycatch {}blocks are rejected. - Process CLI tests (
run): Spawn the binary intest/integration/only for pipes, signals, or processes that outlive the caller (cli-run-parity.integration.test.tspins parity withrunInProcess). - Paired fixtures: A subject tested in both Unit and Integration shares
test/fixtures/<name>-fixtures.ts.
Priorities
FastAgent is a developer-experience product. Its promise is that an existing agent definition becomes a service without being rewritten. When the following conflict, the earlier one wins; name the trade-off when you break one.
- The author's velocity: fast
dev/start, every failure actionable,initcomplete by default. - Incremental change, for authors and for this code: migrate in place rather than rewrite.
- Clarity: show the right complexity where the user meets it, with plain names and APIs.
- Re-evaluate assumptions as models, clouds and harnesses change. Do not stack complex abstractions on complex systems.
- Option value: clear API boundaries and modular seams across
@fastagent-sh/client,pi-durable, anddsh. Keep extensions and transport seams minimal without breaking the shared contract.
Workflow
CONTRIBUTING.md has the full workflow: branches, the PR loop, releases, merge and review policy.
- Iterate with the guards and domain tests for what you changed (
npm run test:guards && npx vitest run test/unit/<domain>/). Before pushing, runnpm run lint && npm run typecheck && npm test, plusnpm run test:integrationwhen the change touches that tier. - Never commit to
main. Use a branch prefix (feature/,fix/,refactor/,docs/,chore/,ci/,test/), thengh pr create --base main --assignee @me. PRs are squash-merged: the PR title and body become the commit, so state the final behavior and its reasons there. - After opening a PR, report it with the local gate result and stop; do not wait for CI. Merge only when a maintainer
says so:
gh pr merge <N> --squash --auto. Report whether the output shows the PR merged or auto-merge enabled. - Clean up a branch only once
gh pr view <N> --json state -q .stateprintsMERGED. gh issue createcannot read the issue forms, so pass--type Bug --label bug(orFeature/enhancement,Task/chore).- Releases publish from CI through npm Trusted Publishing, never with a local
npm publish(CONTRIBUTING.md, "Releases").
Communication
Code, comments, commits, PRs, reviews, issues, release notes, and primary documentation are in English. User-facing
documentation also maintains a Simplified Chinese mirror (README.zh-CN.md and docs/zh-CN/), kept in sync with
the code and English originals. The reader is a senior engineer with full context. Lead with the conclusion, use tables
for comparisons, do not restate, and cut what loses no information.
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.

