lantern
AGENTS.md29 starsChanged 4 months agoMITView on GitHub
Conventional Commits: type: description Release Note Awareness: Type Selection: Critical: fix only for user-facing bugs. Internal fixes (linter errors, type errors, build scripts) use chore. Message Quality Examples: Lantern read Claude Code session logs straight from JSONL files (~/.claude/projects/), zero data loss. Web client shipped as CLI tool serving Vite app. Core Architecture: Project aims for fast feedback plus quality (checks pass = runtime correctness near-guaranteed) via: Implement in t-wada TDD style. pnpm gatecheck check run all above checks against…
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,337 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 repository2 other files it gives its agents.
- docs/agents.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
The file
We split this AGENTS.md into the rules it gives an agent
12 rules. About 0 are common, 5 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
7
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 11
Use as type casting anywhere, tests included (explain problem to user instead)
- Very specific: line 12
Use raw fetch or bypass TanStack Query for API calls
- Very specific: line 13
Run pnpm dev or pnpm start (dev servers)
- Very specific: line 14
Use node:fs, node:path, etc.
- Very specific: line 21
Run pnpm typecheck and pnpm fix before commit
- Distinctive: line 29
Commit messages ship in release notes.
- Distinctive: line 76
After source change, always run before commit:
- Distinctive: line 120
Use Effect-TS only when side effects or state needed
- Distinctive: line 125
No class-based implementations or mutable variables for state
- Distinctive: line 126
Use Effect-TS functional patterns for state
- Very specific: line 154
If types seem unsolvable without as, explain problem to user and ask for guidance
- Very specific: line 206
Session Logs: Read ~/.claude/projects/ JSONL files to learn data structures
≈ “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
Critical Rules (Read First)
Language:
- Code, comments, commits in English
NEVER:
- Use
astype casting anywhere, tests included (explain problem to user instead) - Use raw
fetchor bypass TanStack Query for API calls - Run
pnpm devorpnpm start(dev servers) - Use
node:fs,node:path, etc. directly (use Effect-TS equivalents)
ALWAYS:
- Effect-TS for all backend side effects
- Hono RPC + TanStack Query for all API calls
- TDD: tests first, then implement
- Run
pnpm typecheckandpnpm fixbefore commit
Commit Message Rules
Conventional Commits: type: description
Release Note Awareness:
- Commit messages ship in release notes. Write for users.
Type Selection:
| Type | Release Note | Purpose |
feat | Features | User-facing new feature |
fix | Bug Fixes | User-impacting bug fix |
chore, ci, build, refactor | Excluded | Internal changes |
Critical: fix only for user-facing bugs. Internal fixes (linter errors, type errors, build scripts) use chore.
Message Quality Examples:
- Bad:
fix: fix lingui error(internal issue) - Bad:
feat: add button(too vague) - Good:
feat: add dark mode toggle to settings - Good:
fix: session list not updating after deletion - Good:
chore: update lingui compiled messages
Project Overview
Lantern read Claude Code session logs straight from JSONL files (~/.claude/projects/), zero data loss. Web client shipped as CLI tool serving Vite app.
Core Architecture:
- Frontend: Vite + TanStack Router + React 19 + TanStack Query
- Backend: Hono (standalone server) + Effect-TS (all business logic)
- Data: Direct JSONL reads, strict Zod validation
- Real-time: Server-Sent Events (SSE) for live updates
Recommended Coding Process
Project aims for fast feedback plus quality (checks pass = runtime correctness near-guaranteed) via:
- Strict typing with Effect-TS and ADT
- Quality constraints pushed into Lint where possible
- Dependency injection and testing with Effect-TS
Implement in t-wada TDD style.
pnpm gatecheck check run all above checks against diff at once. Loop: detect problem, fix, repeat.
Gives fast static checks plus unit tests.
Quality Gate (MUST follow)
After source change, always run before commit:
pnpm gatecheck check
./scripts/lingui-check.shKey Directory Patterns
src/server/hono/route.ts- Hono API routes (all routes here)src/server/core/- Effect-TS business logic (domain modules: session, project, git, etc.)src/lib/conversation-schema/- Zod schemas for JSONL validationsrc/testing/layers/- Reusable Effect test layers (testPlatformLayeris foundation)src/routes/- TanStack Router routessrc/cli/- Interactive CLI:initwizard andbrowseboard
The CLI (src/cli/)
lantern init and lantern browse render terminal UI with Ink (React) while driving backend
Effect services directly, so belong to neither src/server nor src/web. Sit outside both —
also what module-boundary lint rule expects: it classifies file by whether path contains
src/server or src/web, gives up otherwise, so src/cli/** may import from either side.
Two rules still apply: no @/ alias outside src/web, and tests colocated.
Three things worth knowing before changing it:
- Behaviour lives in pure functions, under
browse/functions/,actions/planAction.tsandinit/steps.ts. Components are wiring. Change to what key does, which question comes next or how emulator launches belongs in one of those, with test, not in.tsx. - The read-only layer stack in
runtime.tsis subset ofstartServer.tsgraph that answers questions about conversations, minus anything that listens, watches or schedules. - Options must be loaded before the layers are built, via
LanternOptionsService.withOptions. Services resolving path during construction — source roots, cache file — would otherwise never see--claude-dir. Server gets away loading them after because it reads per request; command that asks one question and exits cannot.
Coding Standards
Backend: Effect-TS
Prioritize Pure Functions:
- Extract logic into pure, testable functions when possible
- Pure functions easier to test, reason about, maintain
- Use Effect-TS only when side effects or state needed
Use Effect-TS for Side Effects and State:
- Mandatory for I/O, async code, stateful logic
- No class-based implementations or mutable variables for state
- Use Effect-TS functional patterns for state
- Reference: https://effect.website/llms.txt
Testing with Layers:
import { expect, test } from "vitest";
import { Effect } from "effect";
import { testPlatformLayer } from "@/testing/layers";
import { yourEffect } from "./your-module";
test("example", async () => {
const result = await Effect.runPromise(yourEffect.pipe(Effect.provide(testPlatformLayer)));
expect(result).toBe(expectedValue);
});Avoid Node.js Built-ins:
FileSystem.FileSystemnotnode:fsPath.Pathnotnode:pathCommand.stringnotchild_process
Enables dependency injection and proper testing.
Type Safety - NO as Casting:
ascasting strictly prohibited- If types seem unsolvable without
as, explain problem to user and ask for guidance - Valid alternatives: type guards, assertion functions, Zod schema validation
Frontend: API Access
Hono RPC + TanStack Query Only:
import { api } from "@/lib/api";
import { useQuery } from "@tanstack/react-query";
const { data } = useQuery({
queryKey: ["example"],
queryFn: () => api.endpoint.$get().then((res) => res.json()),
});Raw fetch and direct requests prohibited.
Tech Standards
- Linter/Formatter: oxlint + oxfmt (not ESLint/Prettier/Biome)
- Type Config:
@tsconfig/strictest - Path Alias:
@/*maps to./src/*
Architecture Details
SSE (Server-Sent Events)
When to Use SSE:
- Deliver session log updates to frontend
- Notify clients of background process state changes
- Never for request-response (use Hono RPC instead)
Implementation:
- Server:
/api/sseendpoint with type-safe events (TypeSafeSSE) - Client:
useServerEventListenerhook for subscriptions
Data Layer
- Single Source of Truth:
~/.claude/projects/*.jsonl - Cache:
~/.lantern/(invalidated via SSE when source changes) - Validation: Strict Zod schemas capture every field
Session Process Management
Claude Code processes stay alive in background (unless aborted), so session continues without changing session-id.
Development Tips
- Session Logs: Read
~/.claude/projects/JSONL files to learn data structures - Fixtures:
fixtures/claude-home/is fake~/.claudedir — demo sessions plus one project per JSONL entry shape. Unit tests read it, and--claude-dir ./fixtures/claude-homeruns app against it. - Effect-TS Help: https://effect.website/llms.txt
- Deeper detail:
docs/dev.mdcovers the build pipeline, test strategy, data layer and release flow.docs/README.mdindexes every other doc.
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.

