agentleFS
PAIR-codePAIR-code/deliberate-lab/AGENTS.md

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

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
  1. Very specific:

    Orient yourself first: Run the workspace overview diagnostic script upon entering the workspace to inspect the bare repo layout, active …

    line 74
  2. Very specific:

    Run everything locally: ./run_locally.sh (in the repo root)

    line 84
  3. Very specific:

    Run npm commands from the repo root using --workspace (or -w):

    line 93
  4. Very specific:

    Run npm run update-schemas from the repo root to fix this (requires Python 3.12+ and uv — see scripts/AGENTS.md for setup).

    line 131
  5. Very specific:

    Do not use relative paths to reach into utils/src/ — always import from @deliberation-lab/utils.

    line 169

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

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 PatternRolePolicy
main/Local trunkNever 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 reviewNever 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 developmentThe 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-forwarded main to origin/main to 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 retrospective skill 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 refreshing pr-<number> evaluation mirrors per the eval-pr skill)
  • git clean -fd
  • git branch -D (always use safe delete git branch -d)
  • Overwriting or discarding uncommitted user changes

Architecture

This is an npm workspaces monorepo with three packages:

WorkspacePathPurpose
@deliberation-lab/utilsutils/Shared TypeScript types, validation, and utilities
functionsfunctions/Firebase Cloud Functions (HTTP endpoints + Firestore triggers)
deliberate-labfrontend/Lit Element + MobX single-page app (Webpack)

Other top-level directories:

  • firestore/ — Firestore security rules, database rules, and indexes
  • docs/ — Jekyll documentation site (GitHub Pages)
  • scripts/ — pip-installable Python API client (deliberate_lab) with auto-generated Pydantic types + a Node.js doctor script (see scripts/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 .nvmrc and functions/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 frontend

Python 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 .css files
  • ESLint uses the flat config format (eslint.config.mjs); the project does not have a .eslintrc.* file
  • @typescript-eslint/no-explicit-any is set to error — do not use any
  • 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:

ValueWhat it does
testLint, format check, and unit tests for all workspaces (no deploy)
functionsBuild + deploy Cloud Functions
frontendBuild + deploy frontend to App Engine
rulesDeploy Firestore security rules
indexesDeploy Firestore indexes
allAll 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    # Jest

Functions 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

FilePurpose
firebase.jsonLocal dev emulator config
firebase-test.jsonEmulator config for CI / test runs
.firebaserc.exampleTemplate for project aliases (copy to .firebaserc)
firestore/firestore.rulesFirestore security rules
firestore/database.rules.jsonRealtime Database rules
firestore/storage.rulesCloud Storage rules
firestore/indexes.jsonFirestore 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:

  1. utils/src/stages/ — types, validation, manager, prompts
  2. functions/src/stages/ — backend endpoint + trigger logic
  3. frontend/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.

SkillPurpose
workspace-overviewInspect environment, Node.js version, worktree topology, and toolchain readiness
workspace-syncSynchronize trunk, mirror PR worktrees, and inspect feature branch drift
eval-prSet up a git worktree to run and evaluate an upstream Pull Request locally
ghClean, untruncated GitHub CLI operations and issue/PR inspection
retrospectiveAI-native Post-Action Reviews using FAR rubric, telemetry mining, and zero-in-flight fixes
pr-test-planEvaluate 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:

DecisionTitleScope
0001Record Agent DecisionsTriad architecture (skills/, AGENTS.md, decisions/)
0002Prefer Self-Diagnosing Scripts Over Documentation BloatActive detection and remediation over static checklists
0003Agent Tooling Output StandardsClean stdout, command provenance, 8KB buffer spillover
0004Repository Layer Taxonomy & Labeling6 repository layers (area:*, runtime:*) and toolchain boundaries

Common pitfalls

  1. Forgetting to rebuild utils — frontend and functions consume the compiled output in utils/dist/. After changing utils source, rebuild it (npm run build -w utils) before testing downstream workspaces, or changes won't be picked up.
  2. Running npm from a subdirectory — always run from the repo root with -w <workspace> (see above).
  3. Editing scripts/deliberate_lab/types.py by hand — this file is auto-generated and will be overwritten by npm run update-schemas.
  4. Missing Java 21 for functions tests — the Firebase emulator requires Java 21. Unit-only tests can be run without it via npm run test:unit -w functions.
  5. Forgetting to run npm run update-schemas — if you change types in utils, CI will fail the schema sync check until schemas are regenerated.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.