deliberate-lab
AGENTS.md97 starsChanged 57 days agoApache-2.0View on GitHub
Deliberate Lab is a platform for running online research experiments on human + LLM group dynamics. This file orients AI coding assistants to the monorepo structure, conventions, and workflows. These AGENTS.md files document conventions that should be followed by default. If a user request conflicts with the guidance here, raise the concern — ask which takes precedence (their idea or the documented convention) before proceeding. Do not modify AGENTS.md files unless the user explicitly asks you to. This repository follows…
- Deletes or force-pushes
- 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 31,774 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 repository10 other files it gives its agents.
- frontend/AGENTS.mdAGENTS.md
- functions/AGENTS.mdAGENTS.md
- scripts/AGENTS.mdAGENTS.md
- utils/AGENTS.mdAGENTS.md
- eval-prSkill
- ghSkill
- pr-test-planSkill
- retrospectiveSkill
- workspace-overviewSkill
- workspace-syncSkill
The file
We split this AGENTS.md into the rules it gives an agent
5 rules. About 0 are common, 0 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
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 74
Orient yourself first: Run the workspace overview diagnostic script upon entering the workspace to inspect the bare repo layout, active …
- Very specific: line 84
Run everything locally: ./run_locally.sh (in the repo root)
- Very specific: line 93
Run npm commands from the repo root using --workspace (or -w):
- Very specific: line 131
Run npm run update-schemas from the repo root to fix this (requires Python 3.12+ and uv — see scripts/AGENTS.md for setup).
- Very specific: line 169
Do not use relative paths to reach into utils/src/ — always import from @deliberation-lab/utils.
≈ “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 — Deliberate Lab (root)
Deliberate Lab is a platform for running online research experiments on human + LLM group dynamics. This file orients AI coding assistants to the monorepo structure, conventions, and workflows.
Keeping AGENTS.md in sync
These AGENTS.md files document conventions that should be followed by
default. If a user request conflicts with the guidance here, raise the
concern — ask which takes precedence (their idea or the documented
convention) before proceeding. Do not modify AGENTS.md files unless the
user explicitly asks you to.
Git safety & worktree workflow
This repository follows a bare Git repository + sibling worktrees layout with a triangle workflow (origin fork vs upstream canonical). Operations are governed by the worktree type:
| Worktree Pattern | Role | Policy |
main/ | Local trunk | Never commit directly. Updated only by fast-forwarding from upstream/main after PRs merge (git merge --ff-only upstream/main && git push origin main). |
pr-<number>/ | Collaborator PR review | Never commit. Read-only sandbox to evaluate peers' in-flight PRs. Updated only via git fetch upstream pull/<id>/head && git reset --hard FETCH_HEAD. |
<id>-<slug>/ | Active development | The only worktrees where development commits occur. |
Committing and pushing in feature worktrees (<id>-<slug>/)
- Staging and committing: Once an implementation plan is approved and changes are verified, the agent is encouraged to stage and create local commits following Conventional Commits (
feat:,fix:,chore:, etc.). Align commit scopes and PR metadata with the 6 repository layers (see Decision 0004). Report the commit in the walkthrough. - Pushing to
origin: Pushing feature branches to your personal fork (origin) is safe and encouraged—GitHub preserves commit history even across rebase force-pushes (--force-with-lease). - Pushing
main: Pushing fast-forwardedmaintoorigin/mainto keep your fork in sync with upstream is safe and expected. - Post-Action Reviews: Upon completing a PR, major feature milestone, or pairing session, consider running a retrospective using the
retrospectiveskill to reflect on friction, capture overturned proposals, and anchor fast-follow items without in-flight scope creep.
[!CAUTION] Never run destructive or hard-to-reverse git commands without confirmation:
git reset --hard(except when refreshingpr-<number>evaluation mirrors per theeval-prskill)git clean -fdgit branch -D(always use safe deletegit branch -d)- Overwriting or discarding uncommitted user changes
Architecture
This is an npm workspaces monorepo with three packages:
| Workspace | Path | Purpose |
@deliberation-lab/utils | utils/ | Shared TypeScript types, validation, and utilities |
functions | functions/ | Firebase Cloud Functions (HTTP endpoints + Firestore triggers) |
deliberate-lab | frontend/ | Lit Element + MobX single-page app (Webpack) |
Other top-level directories:
firestore/— Firestore security rules, database rules, and indexesdocs/— Jekyll documentation site (GitHub Pages)scripts/— pip-installable Python API client (deliberate_lab) with auto-generated Pydantic types + a Node.js doctor script (seescripts/AGENTS.md)emulator_test_config/— Static config for Firebase emulator imports
The Firestore data model (document hierarchy, trigger paths) is documented
in functions/AGENTS.md.
Dependency graph
utils ──► frontend
│
└────► functions
·
·····► scripts/types.py (auto-generated via npm run update-schemas)utils is a shared library consumed by both frontend and functions.
Always build utils first — the other two workspaces depend on it.
Getting started
- Orient yourself first: Run the workspace overview diagnostic script upon
entering the workspace to inspect the bare repo layout, active worktrees, remotes,
and verify Node.js readiness:
./.agents/skills/workspace-overview/scripts/workspace-overview.sh - Node 22 is strictly required (see
.nvmrcandfunctions/package.json). Because non-interactive subshells often lack shell initialization (like NVM) or inherit a mismatched host Node version, prefer persistent terminal sessions if available in your agent harness so that an initialized Node 22 environment persists across command invocations throughout the session. - Install all dependencies from the repo root:
npm ci - Run everything locally:
./run_locally.sh(in the repo root) - Diagnose setup problems:
npm run doctor
run_locally.sh copies required config files (.firebaserc,
firebase_config.ts, index.html) if they are missing, builds utils and
functions, starts file watchers for both, launches the Firebase emulators
(with seed data from emulator_test_config/), and serves the frontend at
http://localhost:4201.
Run npm commands from the repo root using --workspace (or -w):
npm run build -w utils
npm test -w functions
npm run start -w frontendPython tooling (uv, pyright) in scripts/ is the exception — run
those from the scripts/ directory where pyproject.toml lives.
Linting & formatting
- Prettier formats
.json,.ts,.html,.scss, and.cssfiles - ESLint uses the flat config format (
eslint.config.mjs); the project does not have a.eslintrc.*file @typescript-eslint/no-explicit-anyis set toerror— do not useany- Husky + lint-staged runs both Prettier and ESLint on pre-commit
for the same file set (
*.{json,ts,html,scss,css}) - Frontend files get browser globals; everything else gets Node globals
CI
cloudbuild.yaml drives all builds. The _DEPLOYMENT_TYPE substitution
variable controls which steps run:
| Value | What it does |
test | Lint, format check, and unit tests for all workspaces (no deploy) |
functions | Build + deploy Cloud Functions |
frontend | Build + deploy frontend to App Engine |
rules | Deploy Firestore security rules |
indexes | Deploy Firestore indexes |
all | All of the above |
GitHub Actions (.github/workflows/ci.yaml) also runs a schema sync
check: if types in utils change, docs/assets/api/schemas.json and
scripts/deliberate_lab/types.py must be regenerated or CI will fail.
Run npm run update-schemas from the repo root to fix this (requires
Python 3.12+ and uv — see scripts/AGENTS.md for setup).
Testing
Each workspace has its own npm test:
npm test -w utils # Jest; unit tests colocated with source
npm test -w functions # Jest; requires Java 21 for Firebase emulator
npm test -w frontend # JestFunctions tests run against the Firebase emulator using
firebase-test.json. The integration test in
cohort_definitions.integration.test.ts is large and slow.
Firebase config
| File | Purpose |
firebase.json | Local dev emulator config |
firebase-test.json | Emulator config for CI / test runs |
.firebaserc.example | Template for project aliases (copy to .firebaserc) |
firestore/firestore.rules | Firestore security rules |
firestore/database.rules.json | Realtime Database rules |
firestore/storage.rules | Cloud Storage rules |
firestore/indexes.json | Firestore composite indexes |
Import convention
Both frontend and functions import from utils using the npm workspace
package name:
import {StageKind, ExperimentConfig} from '@deliberation-lab/utils';Do not use relative paths to reach into utils/src/ — always import
from @deliberation-lab/utils.
Stage system
Experiments are composed of ordered stages (chat, survey, chip
negotiation, ranking, etc.). The StageKind enum in
utils/src/stages/stage.ts lists all stage types.
Adding a new stage type touches all three workspaces:
utils/src/stages/— types, validation, manager, promptsfunctions/src/stages/— backend endpoint + trigger logicfrontend/src/components/stages/— config, preview, and answer UI components
See each workspace's AGENTS.md for detailed guidance.
Skills
Reusable AI agent skills are defined in .agents/skills/. Each skill is a
directory containing a SKILL.md instruction file (with YAML frontmatter)
and optional helper scripts, examples, and resources.
| Skill | Purpose |
workspace-overview | Inspect environment, Node.js version, worktree topology, and toolchain readiness |
workspace-sync | Synchronize trunk, mirror PR worktrees, and inspect feature branch drift |
eval-pr | Set up a git worktree to run and evaluate an upstream Pull Request locally |
gh | Clean, untruncated GitHub CLI operations and issue/PR inspection |
retrospective | AI-native Post-Action Reviews using FAR rubric, telemetry mining, and zero-in-flight fixes |
pr-test-plan | Evaluate PRs for participant/experimenter UX changes and synthesize 7-part manual experiment test plans |
To inspect GitHub issues and pull requests, use the gh skill scripts (./.agents/skills/gh/scripts/gh-issue-view.sh <number> for issues or ./.agents/skills/gh/scripts/gh-pr-view.sh <number> for PRs with CI checks and inline reviews) to stream complete context without terminal truncation.
Decisions
Architectural, toolchain, and governance precedents are recorded in
.agents/decisions/ as lightweight Decision Records with YAML frontmatter
(see 0001-record-agent-decisions.md).
Consult these records just-in-time when resolving architectural or policy ambiguity:
| Decision | Title | Scope |
0001 | Record Agent Decisions | Triad architecture (skills/, AGENTS.md, decisions/) |
0002 | Prefer Self-Diagnosing Scripts Over Documentation Bloat | Active detection and remediation over static checklists |
0003 | Agent Tooling Output Standards | Clean stdout, command provenance, 8KB buffer spillover |
0004 | Repository Layer Taxonomy & Labeling | 6 repository layers (area:*, runtime:*) and toolchain boundaries |
Common pitfalls
- Forgetting to rebuild
utils—frontendandfunctionsconsume the compiled output inutils/dist/. After changingutilssource, rebuild it (npm run build -w utils) before testing downstream workspaces, or changes won't be picked up. - Running
npmfrom a subdirectory — always run from the repo root with-w <workspace>(see above). - Editing
scripts/deliberate_lab/types.pyby hand — this file is auto-generated and will be overwritten bynpm run update-schemas. - Missing Java 21 for
functionstests — the Firebase emulator requires Java 21. Unit-only tests can be run without it vianpm run test:unit -w functions. - Forgetting to run
npm run update-schemas— if you change types inutils, CI will fail the schema sync check until schemas are regenerated.
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.

