RuleStack

Configs

Stacks

Compare

Diff

RuleStack

Configs

Stacks

Compare

Diff

Read API

RuleStack

Configs

Stacks

Compare

Diff

Read API

Configs/AGENTS.md/anomalyco/opencode

AGENTS.md

packages/opencode/AGENTS.md
AGENTS.md

Quality

81/100

Scores the file, not the repository.

Length

873 words

15 headings · 4 code blocks

Repository

193k

— · pushed 0 days ago

Last changed

3 days ago

First indexed 3 days ago.
anomalyco/opencode/packages/opencode/AGENTS.mdRawGitHub
1# opencode database guide
2 
3## Database
4 
5- **Schema**: Drizzle schema lives in `packages/core/src/**/*.sql.ts`.
6- **Migrations**: database migrations live in `packages/core` and are applied by core.
7 
8## Development server
9 
10- Running `bun dev` from `packages/opencode` starts the live interactive TUI. Do not run it as a blocking foreground command when you need to inspect the result.
11- Start it in `tmux` instead: `tmux new-session -d -s opencode-dev 'bun dev'`.
12- Capture the current TUI output with: `tmux capture-pane -pt opencode-dev`.
13- Stop the session explicitly when done: `tmux kill-session -t opencode-dev`.
14 
15# Module shape
16 
17Do not use `export namespace Foo { ... }` for module organization. It is not
18standard ESM, it prevents tree-shaking, and it breaks Node's native TypeScript
19runner. Use flat top-level exports combined with a self-reexport at the bottom
20of the file:
21 
22```ts
23// src/foo/foo.ts
24export interface Interface { ... }
25export class Service extends Context.Service<Service, Interface>()("@opencode/Foo") {}
26export const layer = Layer.effect(Service, ...)
27export const defaultLayer = layer.pipe(...)
28 
29export * as Foo from "./foo"
30```
31 
32Consumers import the namespace projection:
33 
34```ts
35import { Foo } from "@/foo/foo"
36 
37yield * Foo.Service
38Foo.layer
39Foo.defaultLayer
40```
41 
42Namespace-private helpers stay as non-exported top-level declarations in the
43same file — they remain inaccessible to consumers (they are not projected by
44`export * as`) but are usable by the file's own code.
45 
46## When the file is an `index.ts`
47 
48If the module is `foo/index.ts` (single-namespace directory), use `"."` for
49the self-reexport source rather than `"./index"`:
50 
51```ts
52// src/foo/index.ts
53export const thing = ...
54 
55export * as Foo from "."
56```
57 
58## Multi-sibling directories
59 
60For directories with several independent modules (e.g. `src/session/`,
61`src/config/`), keep each sibling as its own file with its own self-reexport,
62and do not add a barrel `index.ts`. Consumers import the specific sibling:
63 
64```ts
65import { SessionRetry } from "@/session/retry"
66import { SessionStatus } from "@/session/status"
67```
68 
69Barrels in multi-sibling directories force every import through the barrel to
70evaluate every sibling, which defeats tree-shaking and slows module load.
71 
72# opencode Effect rules
73 
74Use these rules when writing or migrating Effect code.
75 
76See `specs/effect/migration.md` for the compact pattern reference and examples.
77 
78## Core
79 
80- Use `Effect.gen(function* () { ... })` for composition.
81- Use `Effect.fn("Domain.method")` for named/traced effects and `Effect.fnUntraced` for internal helpers.
82- `Effect.fn` / `Effect.fnUntraced` accept pipeable operators as extra arguments, so avoid unnecessary outer `.pipe()` wrappers.
83- Use `Effect.callback` for callback-based APIs.
84- Use `Effect.void` instead of `Effect.succeed(undefined)` or `Effect.succeed(void 0)`.
85- Prefer `DateTime.nowAsDate` over `new Date(yield* Clock.currentTimeMillis)` when you need a `Date`.
86 
87## Module conventions
88 
89- In `src/config`, follow the existing self-export pattern at the top of the file (for example `export * as ConfigAgent from "./agent"`) when adding a new config module.
90 
91## Schemas and errors
92 
93- Use `Schema.Class` for multi-field data.
94- Use branded schemas (`Schema.brand`) for single-value types.
95- Use `Schema.TaggedErrorClass` for typed errors.
96- Use `Schema.Defect` instead of `unknown` for defect-like causes.
97- In `Effect.gen` / `Effect.fn`, prefer `yield* new MyError(...)` over `yield* Effect.fail(new MyError(...))` for direct early-failure branches.
98 
99## Runtime vs InstanceState
100 
101- Use `makeRuntime` (from `src/effect/run-service.ts`) for all services. It returns `{ runPromise, runFork, runCallback }` backed by a shared `memoMap` that deduplicates layers.
102- Use `InstanceState` (from `src/effect/instance-state.ts`) for per-directory or per-project state that needs per-instance cleanup. It uses `ScopedCache` keyed by directory — each open project gets its own state, automatically cleaned up on disposal.
103- If two open directories should not share one copy of the service, it needs `InstanceState`.
104- Do the work directly in the `InstanceState.make` closure — `ScopedCache` handles run-once semantics. Don't add fibers, `ensure()` callbacks, or `started` flags on top.
105- Use `Effect.addFinalizer` or `Effect.acquireRelease` inside the `InstanceState.make` closure for cleanup (subscriptions, process teardown, etc.).
106- Use `Effect.forkScoped` inside the closure for background stream consumers — the fiber is interrupted when the instance is disposed.
107- To make a service's `init()` non-blocking, fork `InstanceState.get(state)` at the `init()` call site (e.g. `Effect.forkIn(scope)`), not by forking work inside the `InstanceState.make` closure. Forking inside the closure leaves state incomplete for other methods that read it.
108- `src/project/bootstrap.ts` already wraps every service `init()` in `Effect.forkDetach`, so `init()` is fire-and-forget in production. Keep `init()` methods synchronous internally; the caller controls concurrency.
109 
110## Effect v4 beta API
111 
112- `Effect.fork` and `Effect.forkDaemon` do not exist. Use `Effect.forkIn(scope)` to fork a fiber into a specific scope.
113 
114## Preferred Effect services
115 
116- In effectified services, prefer yielding existing Effect services over dropping down to ad hoc platform APIs.
117- Prefer `FileSystem.FileSystem` instead of raw `fs/promises` for effectful file I/O.
118- Prefer `ChildProcessSpawner.ChildProcessSpawner` with `ChildProcess.make(...)` instead of custom process wrappers.
119- Prefer `HttpClient.HttpClient` instead of raw `fetch`.
120- Prefer `Path.Path`, `Config`, `Clock`, and `DateTime` when those concerns are already inside Effect code.
121- For background loops or scheduled tasks, use `Effect.repeat` or `Effect.schedule` with `Effect.forkScoped` in the layer definition.
122 
123## Effect.cached for deduplication
124 
125Use `Effect.cached` when multiple concurrent callers should share a single in-flight computation rather than storing `Fiber | undefined` or `Promise | undefined` manually. See `specs/effect/migration.md` for the full pattern.
126 
127## Callback boundaries
128 
129Use `EffectBridge` for native or external callbacks (`@parcel/watcher`, `node-pty`, native `fs.watch`, plugin callbacks, etc.) that need to re-enter Effect services with instance/workspace context.
130 
131Plain async code should pass explicit context or stay inside an Effect fiber; do not add ambient instance context shims.
132 

Commands it names

  • bun dev
  • node-pty

Sections

  • opencode database guide
  • Database
  • Development server
  • Module shape
  • When the file is an `index.ts`
  • Multi-sibling directories
  • opencode Effect rules
  • Core
  • Module conventions
  • Schemas and errors
  • Runtime vs InstanceState
  • Effect v4 beta API
  • Preferred Effect services
  • Effect.cached for deduplication
  • Callback boundaries

What it covers

code-styledatabaseapido-not

Stack — with the evidence

typescript

(1.00)

bun

(1.00)

turborepo

(1.00)

node

(0.95)

monorepo

(0.85)

react

(0.70)

solid

(0.70)

drizzle

(0.70)

postgres

(0.70)

tailwind

(0.70)

vite

(0.70)

playwright

(0.70)

cloudflare

(0.70)

aws

(0.70)

javascript

(0.60)

docker

(0.60)

github-actions

(0.60)

Format

AGENTS.md

A plain-markdown README for coding agents, deliberately unopinionated: no frontmatter, no globs, no vendor keys. That minimalism is why it became the one file a dozen different agents will read, and why it carries the least per-file targeting power of any format here.

What the corpus says about it

Repository

Owner
anomalyco
Language
—
License
—
Archived
no

All configs in this repo

Also in anomalyco/opencode

Diff this repo’s formats

One repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?

The other instruction files in this repository
RepositoryFormatStackCoversScoreChanged
anomalyco/opencodeAGENTS.md · 193kAGENTS.mdtypescriptbun+14testlint-formatstyletypes+380/1003 days ago
anomalyco/opencodepackages/app/AGENTS.md · 193kAGENTS.mdtypescriptbun+14style56/1003 days ago
anomalyco/opencodepackages/app/e2e/performance/AGENTS.md · 193kAGENTS.mdtypescriptbun+14no sections16/1003 days ago
anomalyco/opencodepackages/codemode/AGENTS.md · 193kAGENTS.mdtypescriptbun+14api43/1003 days ago
anomalyco/opencodepackages/core/src/tool/AGENTS.md · 193kAGENTS.mdtypescriptbun+14stylesecurity58/1003 days ago
anomalyco/opencodepackages/effect-drizzle-sqlite/AGENTS.md · 193kAGENTS.mdtypescriptbun+14database38/1003 days ago
anomalyco/opencodepackages/llm/AGENTS.md · 193kAGENTS.mdtypescriptbun+14stylearchtesting-strategygit+157/1003 days ago
anomalyco/opencodepackages/opencode/src/server/routes/instance/httpapi/AGENTS.md · 193kAGENTS.mdtypescriptbun+14styleapi40/1003 days ago
anomalyco/opencodepackages/opencode/src/session/llm/AGENTS.md · 193kAGENTS.mdtypescriptbun+14arch61/1003 days ago
anomalyco/opencodepackages/opencode/test/AGENTS.md · 193kAGENTS.mdtypescriptbun+14teststylearchtesting-strategy+181/1003 days ago
anomalyco/opencodepackages/opencode/test/server/AGENTS.md · 193kAGENTS.mdtypescriptbun+14teststyleapi38/1003 days ago
anomalyco/opencodepackages/schema/AGENTS.md · 193kAGENTS.mdtypescriptbun+14styletypesdatabaseapi+165/1003 days ago
Diff against AGENTS.md Diff against packages/app/AGENTS.md Diff against packages/app/e2e/performance/AGENTS.md Diff against packages/codemode/AGENTS.md Diff against packages/core/src/tool/AGENTS.md Diff against packages/effect-drizzle-sqlite/AGENTS.md Diff against packages/llm/AGENTS.md Diff against packages/opencode/src/server/routes/instance/httpapi/AGENTS.md Diff against packages/opencode/src/session/llm/AGENTS.md Diff against packages/opencode/test/AGENTS.md Diff against packages/opencode/test/server/AGENTS.md Diff against packages/schema/AGENTS.md

Similar configs

Same format, overlapping stack, ranked by quality.

Same format, overlapping stack, ranked by quality
RepositoryFormatStackCoversScoreChanged
aaif-goose/gooseAGENTS.md · 52kAGENTS.mdrusttypescript+2setupbuildtestlint-format+6100/1003 days ago
n8n-io/n8npackages/@n8n/agents/AGENTS.md · 199kAGENTS.mdtypescriptlangchain+16buildteststylearch+3100/1003 days ago
duckduckgo/content-scope-scriptsspecial-pages/AGENTS.md · 70AGENTS.mdtypescriptjavascript+5buildteststylearch+3100/1003 days ago
code-yeongyu/oh-my-openagentpackages/web/AGENTS.md · 67kAGENTS.mdtypescriptbun+10setupbuildtestlint-format+6100/1002 days ago
mui/material-uiAGENTS.md · 99kAGENTS.mdtypescriptjavascript+13setupbuildtestlint-format+9100/1003 days ago
TryGhost/Ghoste2e/AGENTS.md · 55kAGENTS.mdtypescriptjavascript+12setupteststylearch+2100/1003 days ago
elastic/elasticsearchx-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/AGENTS.md · 78kAGENTS.mdjavanode+4buildtestlint-formatstyle+2100/1003 days ago
elastic/elasticsearchx-pack/plugin/inference/AGENTS.md · 78kAGENTS.mdjavanode+4buildtestlint-formatstyle+3100/1003 days ago
RuleStack

Built by

Kynth Studio

Directory

Configs
Stacks
Compare formats
Diff two configs
Best AGENTS.md examples

Formats

AGENTS.md
CLAUDE.md
Cursor rules
Copilot instructions

Reference

Read API
Corpus health
Privacy Policy
Terms

RuleStack

RuleStack

Built by

Kynth Studio

Directory

Configs
Stacks
Compare formats
Diff two configs
Best AGENTS.md examples

Formats

AGENTS.md
CLAUDE.md
Cursor rules
Copilot instructions

Reference

Read API
Corpus health
Privacy Policy
Terms

RuleStack

RuleStack

Built by

Kynth Studio

Directory

Configs
Stacks
Compare formats
Diff two configs
Best AGENTS.md examples

Formats

AGENTS.md
CLAUDE.md
Cursor rules
Copilot instructions

Reference

Read API
Corpus health
Privacy Policy
Terms

RuleStack