BERIL Research Observatory - Onboarding
Welcome the user and orient them to the system, then route them to the right context based on their goal.
Phase 1: System Overview
Present this information directly (no file reads needed):
What is BERDL?
The KBase BER Data Lakehouse (BERDL) is an on-prem Iceberg Lakehouse (Spark SQL) hosting databases across multiple tenants. The exact database inventory and access depend on the authenticated user — discover it live in Phase 1.6 below.
Collections currently span: pangenomes (GTDB-derived species pangenomes with functional annotations and pathway predictions), genome structural data, biochemistry (ModelSEED reactions and compounds), genome-wide fitness (RB-TnSeq), environmental microbiology, multi-omics (NMDC), phage-host data, and marine microbial samples. Always discover the exact set live — do not rely on this prose for current inventory.
Repo Structure
projects/ # Science projects (each has README.md + notebooks/ + data/)
docs/ # Shared knowledge base
schemas/ # Per-collection table/column docs
pitfalls.md # SQL gotchas, data sparsity, common errors
performance.md # Query strategies for large tables
research_ideas.md # Future research directions
overview.md # Scientific context and data generation workflow
discoveries.md # Running log of insights
.claude/skills/ # Agent skills
data/ # Shared data extracts reusable across projects
Available Skills
| Skill | What it does |
|-------|-------------|
| /berdl | Discover BERDL data with access-aware helpers and query with Spark SQL |
| /berdl-query | Run SQL queries locally with remote Spark compute (CLI tools + notebook support) |
| /berdl-minio | Transfer files between BERDL MinIO and local machine |
| /berdl-discover | Explore and document a new BERDL database |
| /research-plan | Turn interests + data + literature into a frozen, pre-registered RESEARCH_PLAN.md (Phase A/B) |
| /execute-plan | Read the frozen plan and build, run, and write up the analysis (Phase C/D) |
| /literature-review | Search PubMed, bioRxiv, arXiv, Semantic Scholar, and Google Scholar for relevant biological literature |
| /synthesize | Read analysis outputs, compare against literature, and draft findings |
| /submit | Approve a project and upload it to the lakehouse |
| /cts | Run batch compute jobs on the CTS cluster |
| /ecosim | Simulate soil, plant and microbe responses to climate or management with the EcoSIM model (optional install) |
Note: Hypothesis generation, research planning, and notebook creation are handled automatically as part of the Unified Project Workflow below. You don't need to invoke them separately.
Existing Projects
Look projects up through the knowledge layer, not by hand — the availability check
and commands are in Phase 1.8. Search projects with
beril context find "<user's topic>", and list them with the per-owner loop in the
knowledge-context skill (§ Common workflows). Present what you find so the user sees
what's been done.
Use a bare ls projects/ only as a quick directory sanity-check or when the knowledge
layer is UNREACHABLE — not as the default way to survey prior work. Reading every
projects/*/README.md by hand is slower and misses the cross-project connections the
knowledge layer surfaces.
How Projects Work
Each project lives in projects/<name>/ with a three-file structure plus supporting directories:
projects/<name>/
├── README.md — Project overview, reproduction, authors
├── RESEARCH_PLAN.md — Hypothesis, approach, query strategy, revision history
├── REPORT.md — Findings, interpretation, supporting evidence
├── REVIEW.md — Canonical copy of the approved review (set by /submit)
├── REVIEW_N.md — Numbered reviews from /berdl-review (history; latest is canonical at submit time)
├── SUBMITTED.md — Marker file written when lakehouse upload succeeds (visible from `ls`)
├── notebooks/ — Analysis notebooks with saved outputs
├── data/ — Agent-derived data from queries and analysis
├── user_data/ — User-provided input data (gene lists, phenotypes, etc.)
├── figures/ — Key visualizations
└── requirements.txt — Python dependencies
Reproducibility is required: notebooks must be committed with outputs, figures must be saved to figures/, and README must include a ## Reproduction section. See PROJECT.md for full standards.
Phase 1.5: Environment Detection
Run the canonical environment check:
python scripts/berdl_env.py --check
This wraps scripts/detect_berdl_environment.py with auto-recovery. It:
- Detects on-cluster vs off-cluster by testing connectivity to
spark.berdl.kbase.us:443. - On-cluster: confirms
KBASE_AUTH_TOKEN, writes to.envif missing, reports ready. - Off-cluster: checks
.env,.venv-berdl, SSH tunnels (1337, 1338), pproxy (8123). Auto-starts pproxy if tunnels are up. Prints exactssh -f -N -D ...commands if tunnels are missing.
Present the output to the user. If exit code is non-zero, follow the printed next steps. Common cases:
- "Start SSH tunnels" → ask the user to run the printed command in a terminal, then re-run
python scripts/berdl_env.py --check. - "pproxy not running" → the helper auto-starts it; this should self-resolve.
- "Missing .venv-berdl" →
bash scripts/bootstrap_client.sh. - "Missing KBASE_AUTH_TOKEN" → sign in at https://hub.berdl.kbase.us, spawn a server, and in a notebook run
import os; print(os.environ.get('KBASE_AUTH_TOKEN')), then add it to.env. Delete the cell output immediately after copying the token; saved outputs live in the notebook file and can be shared or committed by accident. The token lasts 14 days, and signing out of KBase revokes it immediately, so do not sign out mid-run. (narrative.kbase.usshows a Developer Tokens tab only to accounts holding theDevTokenrole, and BERDL uses Login tokens.)
Route follow-up BERDL queries from the detected location:
on-cluster: use the active Spark session andspark.sql(query)directly. Do not use--berdl-proxy.off-cluster: use/berdl-queryorpython scripts/run_sql.py --berdl-proxyafter the helper reports ready.
Do not skip this step. The location reported is what every subsequent skill in this session uses to choose its execution path.
Phase 1.6: Live Inventory
After Phase 1.5 reports ready, print the live database inventory:
python scripts/berdl_inventory.py
Cache-backed (fast on repeat runs). The first run does a live fetch and caches the result to data/berdl_inventory_cache.json (keyed by environment + auth token). Subsequent runs within 7 days serve from that cache in a fraction of a second without touching Spark; past 7 days the script auto-refetches once. The stdout summary and data/berdl_inventory.md both carry a freshness banner — paste that banner verbatim so the user sees how old the data is (e.g. "Cached 3 days ago …").
If any database fails to list (e.g. a transient auth error), the banner says partial and the run is not cached, so the next run retries rather than serving a lossy inventory for a week. Relay that banner too — the table counts are undercounted on such a run.
To force a refresh at any time:
python scripts/berdl_inventory.py --refresh
This is plain python in both environments. It auto-detects on-cluster vs off-cluster and picks the right discovery path.
- On-cluster (JupyterHub): the JH kernel already has every import. Just run the command above.
- Off-cluster (local machine): activate
.venv-berdlfirst (source .venv-berdl/bin/activate), then run the command above. If the venv isn't bootstrapped yet, runbash scripts/bootstrap_client.sh. Ad-hoc alternative without venv:uv run --with pyspark --with "spark_connect_remote @ git+https://github.com/KBaseDataLakehouse/spark_connect_remote.git" --with "berdl_remote @ git+https://github.com/KBaseDataLakehouse/berdl_remote.git" scripts/berdl_inventory.py.
Do not use a bare uv run scripts/berdl_inventory.py (without --with) — uv run --script would create an isolated venv that excludes both the JH kernel's berdl_notebook_utils (breaks on-cluster) and the off-cluster Spark deps. The script detects misuse and exits with an actionable message, but pick the right invocation upfront.
Output contract: the script prints a compact tenant-level summary (header + one row per tenant + "other tenants" footer) to stdout, and writes the full per-database markdown report to data/berdl_inventory.md. This split exists because the Claude Code UI auto-collapses long bash output to "+N lines (ctrl+o to expand)" — keeping stdout short means the summary actually surfaces, and the file gives the user a stable artifact they can open in their editor regardless of how the chat displays bash output.
What you need to do in your reply:
- Paste the stdout summary verbatim (it's short — the AGENT comment at the end of the summary reinforces this).
- Tell the user the full per-database report is at
data/berdl_inventory.md. Do NOT try to relay that file's contents into chat unless the user explicitly asks — they can open it directly. - If the user asks for a specific tenant's databases, use
Readondata/berdl_inventory.mdand excerpt just that section, OR re-run withpython scripts/berdl_inventory.py --fulland quote the relevant block.
Same command works on-cluster and off-cluster — on-cluster it uses access-aware berdl_notebook_utils.get_db_structure() plus list_tenants() / get_tenant_detail() for tenant metadata. Off-cluster (with .venv-berdl active), the script falls back to SHOW DATABASES + SHOW TABLES via the local Spark Connect drop-in (which auto-spawns the JH server on cold start). Tenant metadata is on-cluster only; off-cluster groups by the database's underscore prefix without descriptions.
Useful flags:
--full— print the full report to stdout instead of the compact summary (also still writes the file unless--no-file).--no-file— skip writingdata/berdl_inventory.md.--output PATH— override the file destination.--sample 5— show up to 5 table names per database in the full report (default: 3).--with-members— list each tenant's read-write and read-only members in the full report.--no-emoji— plain-text output.--off-cluster— force the off-cluster path.--refresh— force a live fetch and rewrite the cache (ignores the 7-day TTL).--no-cache— one-shot live fetch that neither reads nor writes the cache.--ttl-days N— override the 7-day cache lifetime (alsoBERDL_INVENTORY_TTL_DAYS).
For deeper inspection, suggest the user run:
DESCRIBE DATABASE EXTENDED <db>— database-level description / location / properties.DESCRIBE EXTENDED <db>.<table>— table-level description, columns, partitioning, storage.berdl_notebook_utils.get_table_schema(db, table, detailed=True, return_json=False)— column-level info (name, type, nullable, description).
Do not run COUNT(*) per database in this phase — it's expensive and not needed for orientation.
NMDC collection orientation
If the inventory or the user's question involves an nmdc database, read
docs/datasets/nmdc/README.md before recommending tables. It distinguishes the
canonical nmdc tenant from derived or scoped kbase.nmdc_* products and gives
the standard biosample-to-result join. Use the live inventory for availability;
use the guide for provenance and resource roles.
Phase 1.7: Session Naming Reminder
If the session does not already have a name, remind the user:
Tip: Name this session for easy identification — especially useful for long-running or remote sessions where the connection may drop. A good convention is to match the project name and git branch (e.g.,
essential_metabolome).
This is a non-blocking reminder. Move on to Phase 2 regardless.
Phase 1.8: Knowledge Layer Check (how to look up projects & prior work)
**By default, look up projects and cross-project knowledge through the knowledge layer
— not by reading projects/ directly.** It is reached through BERIL with the user's
beril login. Confirm it's available once:
beril context doctor
- OK → use the
knowledge-contextskill for all cross-project lookups —
finding projects, "what's known about X", "has this been done", "related work":
- by topic:
beril context find "<topic>" - exact term / author / db:
beril context grep "<term>" --all-owners - known gotchas:
beril context pitfalls "<error or table>" - list projects: the per-owner
lsloop inknowledge-context§ Common workflows
**Do not enumerate projects/ or read projects/*/README.md / REPORTs by hand for
context** — the knowledge layer indexes and ranks submitted projects, including ones
not in this checkout, and hand-scanning misses the cross-project connections it
surfaces. One exception: indexing is best-effort (a submitted project's mirror can be
skipped or fail — see knowledge-context § How content gets in), so **before
concluding that no prior work exists**, also check ls projects/ in this checkout.
- NOT_LOGGED_IN / AUTH_FAILED → tell the user to run
beril loginin their own
terminal (it asks for a personal access token created at <BERIL URL>/account/tokens), then
continue — non-blocking, don't wait on it.
- UNREACHABLE / UNAVAILABLE → BERIL or its context layer is down. There is no
offline mode: tell the user, and until it's back fall back to this checkout's own
files (ls projects/, docs/{pitfalls,discoveries,performance}.md) with your normal
tools — say plainly that recall is partial (no semantic search, nothing submitted
from elsewhere).
Non-blocking (like the session-naming reminder) — proceed to Phase 2 regardless.
**Reserve hand-reading projects/<id>/ files for the one project you're actively
working in, never as the way to discover what exists or what's been done.**
Phase 2: Establish Project Context
Every BERIL session works inside a project — including ad-hoc exploration. This gives every artifact (queries, user data, notes, figures) a home from minute one, makes work resumable across sessions, and avoids loose exploratory/ clutter.
Ask the user which of these applies:
- Continue an existing project — pick from
projects/*(recommended if any work is in flight) - Start a new project — name it now (e.g.,
metal_cofitness,lanthanide_genomes) - I'm just exploring — agent uses
scratch_<YYYYMMDD>(or<topic>_scratchif the user gives a keyword)
There is no "no-project" door. If the user truly wants only to learn about the system without committing to a session, point them at the Side Path at the end of this skill — that's reading, not a session.
Once a project context is established, the workflow is the same regardless of entry door:
| Phase | Status (beril.yaml) | What happens |
|---|---|---|
| Phase 0 — Scaffold | (unset → exploration) | Create dirs, beril.yaml, stub README; pick branch. Runs only for entry doors 2 and 3. |
| Phases A & B — Exploration & Research Plan | exploration → proposed | /research-plan: explore data, frame the question, draft competing hypotheses, write the frozen RESEARCH_PLAN.md. STOP at the plan-review checkpoint. |
| Checkpoint — Plan Review | proposed | Mandatory pause (owned by /research-plan): approve, review, or iterate. Do not skip. |
| Phases C & D — Analysis & Synthesis | proposed → active → analysis | /execute-plan: run the planned notebooks (discriminating query first), then /synthesize → REPORT.md. |
| Phase E1 — Review | analysis → reviewed | /berdl-review produces a numbered REVIEW_N.md with hash footer. Iterate freely. |
| Phase E2 — Approve & Submit | reviewed → complete (+ SUBMITTED.md on upload success) | /submit verifies the latest review is current, asks for explicit approval, uploads to lakehouse, writes marker file. |
For entry door 1 (Continue existing): start at the phase matching the project's current status and route to the owning skill (exploration/proposed → /research-plan; active → /execute-plan; analysis → /berdl-review; reviewed → /submit). For doors 2 and 3: start at Phase 0.
Unified Project Workflow
The flow below applies regardless of entry door. Doors 2 and 3 (new project, just exploring) start at Phase 0. Door 1 (continue existing) skips Phase 0 and resumes at the phase matching the project's current status in beril.yaml.
Phase 0: Project Scaffold (entry doors 2 and 3 only)
Establish the project directory and manifest before any querying, planning, or user-data handoff. This guarantees every artifact has a home from the first command.
- Resolve project name:
- Door 2 (new project): ask for a snake_case identifier (e.g.,
metal_cofitness,lanthanide_genomes). - Door 3 (just exploring): default to
scratch_<YYYYMMDD>. If the user mentioned a topic keyword (e.g., "metal cofitness"), use<topic>_scratch.
- Verify uniqueness:
projects/<id>/must not already exist. If it does, ask whether to switch to door 1 (continue existing) or pick a new name. - Author identity: run
beril user --jsonvia Bash. The JSON hasname,affiliation,orcid. Exit 0 = all three present, use them. Exit 1 = at least one missing; parse the JSON anyway, prompt only for missing fields, then suggestberil setupto persist. - Create directories:
projects/<id>/{notebooks,data,user_data,figures}. Add a.gitkeepfile in each (touch projects/<id>/notebooks/.gitkeepetc.) so git tracks the directories through the scaffold commit. Without.gitkeep, the empty dirs are dropped from the commit and the "every artifact has a home" promise breaks on checkout elsewhere. - Write
beril.yaml(template at the bottom of this file):status: exploration,created_atandlast_session_atset to current ISO timestamp,engine.nameset to the current agent (e.g.,claude), authors from beril user, allartifactsflags false initially.branchis set in step 6. - Branch (recommended): offer to create branch
projects/<id>and switch to it. Long-running projects onmaincreate merge pain. If the user declines, leave on the current branch. Record the actual branch inberil.yaml. - Write a stub
README.md(template at the bottom): title (humanized from project_id), Status block reading "Exploration — research plan not yet written", authors from beril user, Quick Links pointing atRESEARCH_PLAN.md(TBD) andREPORT.md(TBD), Reproduction placeholder. - Update
beril.yaml:artifacts.readme: true. - Append a worklog entry (
project scaffolded → exploration) recording what the user came in wanting to find out — see.claude/skills/worklog-capture/SKILL.md. - Commit:
feat(project): scaffold {id} (exploration phase). - Suggest naming this session to match the project: "Consider naming this session
{project_id}to match the branch — useful for long-running or remote sessions where the connection may drop."
After Phase 0, every artifact has a home. User data → projects/<id>/user_data/. Exploration queries → projects/<id>/notebooks/00_*.ipynb. References → projects/<id>/references.md. Move on to Phases A & B — invoke /research-plan.
Phases A & B: Exploration & Research Plan → invoke `/research-plan`
Status: exploration → proposed. The detailed steps for orientation, exploration, framing the question, drafting competing hypotheses, feasibility, and writing the frozen RESEARCH_PLAN.md now live in the /research-plan skill.
Invoke /research-plan {project_id}. It owns:
- Phase A orientation & exploration (required reading, live data discovery, user-data handoff, literature).
- Phase B planning: a FINER/PICO research question; competing hypotheses (H0/H1 + genuine rivals, drafted before asking the user's preference); per-hypothesis prediction + falsification test + decision criteria; the discrimination strategy and confidence prior; a feasibility verdict via cheap probes; a per-notebook Analysis Plan; and
RESEARCH_PLAN.md(whose enriched template now lives in that skill). - Setting
beril.yamlstatus: proposed. - The mandatory plan-review checkpoint (kept and owned by
/research-plan): present the plan, then offer (a) approve and start analysis, (b) independent review viatools/review.sh --type planand/or the hypothesis-critic agent, (c) iterate. It does not advance to analysis until the user picks (a). See Key Principle 6 below — never skip this checkpoint.
Phases C & D: Analysis & Synthesis → invoke `/execute-plan`
Status: proposed → active → analysis. The detailed steps for building and running the planned notebooks, the revision loop, the results checkpoint, and synthesis now live in the /execute-plan skill.
Invoke /execute-plan {project_id}. It owns:
- Reading the frozen
RESEARCH_PLAN.mdand confirming the plan-review checkpoint was approved — theplan_approvalblock inberil.yaml, recorded byuv run beril approve <id>(a human at a terminal, or the agent with--relayedwhen the user approved in conversation —viarecords which);statusis not approval. - Phase C analysis:
status: proposed → active; per planned notebook, running the discriminating/refuting query first (Platt), producing the expected output, executing, committing, and capturing pitfalls. - The revision loop: a minor deviation is logged to Revision History and execution continues; a material change to the pre-registered contract demotes
active → proposedand re-runs the plan-review checkpoint. - The results-review checkpoint, then Phase D synthesis via
/synthesize(status: active → analysis). - Handing off to the existing back of the arc (
/berdl-review+/submit).
Phase E1: Review (`analysis` → `reviewed`)
Status transition handled by /berdl-review. The user can iterate freely — different models, multiple opinions — each run produces a numbered REVIEW_N.md. Each review file embeds a <!-- report_hash: sha256:... --> footer (written by tools/review.sh) so /submit can later confirm the review covers the current REPORT.md.
- Run
/berdl-review {project_id}(or with--reviewer codexfor a different model). After the first successful review, status flips fromanalysistoreviewed. - If issues are raised that need the report or notebooks updated, address them. If
REPORT.mdchanges (re-running/synthesize), the project silently demotes back toanalysisand existing reviews go stale via hash mismatch — run/berdl-reviewagain to produce a current review. - When the review looks good (or has only issues the user is comfortable approving despite), proceed to Phase E2.
Phase E2: Approve & Submit (`reviewed` → `complete`)
Status transition handled by /submit. The lifecycle treats complete as a human act: the user, as the responsible author, explicitly says "yes, this is done." Lakehouse upload follows; on success a visible SUBMITTED.md marker lands in the project so anyone can see at a glance that the project was submitted.
- Run
/submit {project_id}. The skill:
1. Runs the pre-submission checklist.
2. Verifies the latest REVIEW_N.md's footer matches the current REPORT.md hash (rejects stale reviews).
3. Verifies a configured ORCID (beril user --json must return one).
4. Asks for explicit approval (y/n).
5. Writes the approval to beril.yaml and copies the approved review to REVIEW.md.
6. Uploads to the lakehouse.
7. Writes SUBMITTED.md (success) or SUBMISSION_FAILED.md (failure). Status flips to complete regardless of upload outcome — the upload is tracked separately via the marker files and beril.yaml.submissions[].
- If upload fails, just re-run
/submitafter fixing the issue (e.g., MinIO config). It recognizes the existing approval and only retries the upload. - Discuss next steps with the user once
SUBMITTED.mdis in place.
Re-opening a complete project
If the user discovers an error after submission and wants to revise: run /synthesize (or edit notebooks then /synthesize). Because status is complete, /synthesize will explicitly ask for confirmation before overwriting REPORT.md and demoting to analysis. The previous approval gets archived under previous_approvals in beril.yaml and both marker files are deleted. Then iterate /berdl-review and /submit again — the second /submit's approval prompt will warn that this replaces the existing lakehouse archive.
Throughout the Workflow
- Commit code often — don't let work accumulate uncommitted.
- Capture pitfalls as you go: when something goes wrong, follow
.claude/skills/pitfall-capture/SKILL.md— it appends toprojects/<id>/memories/pitfalls.md(per-project, append-only with corrections). Don't write to the centraldocs/pitfalls.md; it's a frozen historical archive. - Capture discoveries and performance notes in REPORT.md: when you find something worth surfacing across projects, draft it in the optional
## Discoveriessection ofREPORT.md(added by/synthesize). Project-specific tuning observations go in## Performance Notes. These flow through/berdl-reviewand get extracted intoprojects/<id>/memories/{discoveries,performance}.mdby/submitat approval — only after review and approval, so the memories layer reflects vetted content. - When debugging or designing queries, check both layers: grep
docs/pitfalls.md(historical archive — still has most of the canonical gotchas) AND scanprojects/*/memories/pitfalls.mdfor recent gotchas hit by related projects (especially the same database family). - Re-read
docs/performance.mdwhen queries are slow — it's still the canonical reference for table-size strategies and anti-patterns. Project-specific tuning hits captured at past approvals live inprojects/*/memories/performance.md. - Follow
PROJECT.mdstandards — notebooks with saved outputs, figures as standalone PNGs,requirements.txt, Reproduction section in README.
Entry Door 1: Continue an Existing Project (resumption)
Phase 0 is skipped. Resume at the phase matching the project's current status.
- Run
ls projects/and list all projects. - For each project, read
beril.yaml(if present) and display:status,last_session_at,branch, and whichartifactsare present/missing. Ifberil.yamlis missing (pre-manifest project), note "no manifest" — still works, just legacy. - The user picks one. Read its
README.md,RESEARCH_PLAN.md, andREVIEW.md(if present). ReadREPORT.mdifartifacts.reportis true. - Update
beril.yaml:last_session_atto now. - Resume detection on
reviewed/complete: before suggesting a phase, validate currency. Thecompletechecks must match what/submitPhase 1a does — otherwise the user could see a project listed ascompletehere and then watch/submitreject it on the same conditions.
Hash comparison rule: stored hashes in beril.yaml.approval.* and the REVIEW footer carry a sha256: prefix; computed hashes from sha256sum (or hashlib) are raw hex. Use tools.notebook_hash.unprefixed() to strip the prefix from stored values before comparing to computed hex. Never compare the prefixed and raw forms directly.
- For
complete: validate all approved content (REPORT.md, the review files, AND notebooks), not just REPORT.md. projects/{id}/REPORT.mdmust exist andsha256sum REPORT.md == unprefixed(approval.report_hash).projects/{id}/REVIEW.mdexists →sha256sum REVIEW.md == unprefixed(approval.review_hash). Missing alone is fine —/submitPhase 3a recreates it from the numbered review.projects/{id}/{approval.review}(numbered file, e.g.REVIEW_3.md) exists → its hash matchesunprefixed(approval.review_hash). Missing alone is fine. Missing together with REVIEW.md is approved-content loss.- Notebook hashes (v5): if
approval.notebook_hashesis present and non-empty, invokepython {repo_root}/tools/notebook_hash.py compute-hashes {project_path}(use absolute paths;/berdl_startmay run from anywhere). Parse the JSON output and compare each entry againstapproval.notebook_hashes. Any mismatch, missing notebook from the approval set, or new notebook in the current set → drift. (Empty / omittednotebook_hashesfield is treated as legacy and skipped.) - Any hash mismatch, OR REPORT.md missing, OR both review files missing, OR a notebook drift → offer demote-to-
analysis. Phrase the prompt to match the cause ("REPORT.md changed since approval", "REVIEW.md changed since approval", "REVIEW_N.md changed since approval", "REPORT.md is missing — restore it from version control", "Both REVIEW.md and REVIEW_N.md missing on a complete project", "notebook(s) changed since approval: <list>", etc.). On Yes: moveapprovaltoprevious_approvals(append) with an addedarchived_at: "<now>"field, setstatus: analysis, update README## Statusto "Analysis — report drafted, awaiting/berdl-reviewand/submit.", deleteREVIEW.mdif present, and delete both marker files. If user declines, warn but leave alone. - For
reviewed: parse the latestREVIEW_N.mdfooter hash (extract the hex aftersha256:) and compare tosha256sum REPORT.md. If mismatch → offer demote-to-analysis(existing reviews stale). On Yes: setstatus: analysis, update README## Statusto "Analysis — report drafted, awaiting/berdl-reviewand/submit." If user declines, warn but leave alone.
- Resume at the phase matching the (possibly demoted) status, routing to the owning skill:
exploration→/research-plan(Phases A & B — explore, then draft and freeze the plan).proposed→/research-plan(re-present the plan and run the plan-review checkpoint — ask the (a)/(b)/(c) question; do not advance to analysis until (a)).active→/execute-plan(Phase C analysis — resume at the next unfinished notebook, discriminating query first).analysis→/berdl-review(Phase E1). IfREPORT.mddoesn't exist yet (rare),/execute-planruns/synthesizefirst (Phase D).reviewed→/submit(Phase E2 — approve & submit).complete:SUBMITTED.mdpresent → "Project complete and submitted on {SUBMITTED.md submitted_at}; archive: {archive_key}. Inspect, reopen for revisions (run/synthesize), or move on?"SUBMISSION_FAILED.mdpresent (or both markers absent) → "Project approved locally but lakehouse upload pending. Re-run/submitto retry."- missing/legacy → infer from artifacts present (REPORT exists →
/berdl-review; RESEARCH_PLAN exists but no REPORT →/execute-plan).
- Suggest the next concrete action based on the resumed phase.
Side Path: Understanding the System (no project)
If the user truly wants only to understand BERIL without committing to a session, point them at:
PROJECT.md— dual goals (science + knowledge capture), structuredocs/overview.md— scientific context and data workflowdocs/pitfalls.md— per-database non-derivable gotchasdocs/research_ideas.md— backlog and future directions
Also explain:
- Current inventory and access should be discovered live with
berdl_notebook_utils.get_databases(return_json=False). - The documentation workflow (tag discoveries, update pitfalls) — captured in
PROJECT.md. - The BERDL JupyterHub UI is browsable at https://hub.berdl.kbase.us.
- The available skills and what each does (table at the top of this skill).
This is reading, not a session. After reading, the user re-invokes /berdl_start to begin actual work — at which point Phase 2's three-door menu applies.
Companion skills used during the workflow
These are project-agnostic helpers — invoke them from inside any project at the right phase:
/berdl— query BERDL with Spark SQL. Used by/research-plan(exploration + feasibility probes) and/execute-plan(analysis)./berdl-query— local-machine variant for off-cluster work./berdl-discover— explore and document a new database that isn't yet indocs/pitfalls.md./berdl-minio— file transfer between BERDL MinIO and local./literature-review— search PubMed, bioRxiv, arXiv, Semantic Scholar, Google Scholar. Writes toprojects/<id>/references.md.
MCP setup check for /literature-review: the paper-search-mcp (openags/paper-search-mcp) is configured in .mcp.json and runs via uvx paper-search-mcp. If it fails:
- Ensure Python 3.10+ and uv are installed.
- Test:
uvx --from paper-search-mcp python -m paper_search_mcp.server. - Optionally set
SEMANTIC_SCHOLAR_API_KEYfor enhanced Semantic Scholar features. - The skill falls back to WebSearch if the MCP server is unavailable.
Key Principles (for the agent)
- Always start in a project — every session establishes a project context (new, existing, or
scratch_<date>) before doing any work. User data, queries, exploration notebooks, references — all live inprojects/<id>/. Never leave artifacts loose in the repo root,~/, orexploratory/. - Read the docs and discover live data first —
PROJECT.md,docs/overview.md,docs/pitfalls.md,docs/performance.mdbefore designing any queries. Useberdl_notebook_utils.get_databases(return_json=False),get_tables(... return_json=False), andget_table_schema(... detailed=True, return_json=False)for live inventory. - Notebooks are the audit trail — numbered sequentially (00 for exploration, 01+ for analysis), each self-contained with a clear purpose. Commit with saved outputs per
PROJECT.mdreproducibility standards. - Commit early and often — after scaffold, after plan, after each notebook, after data extraction, after analysis, after synthesis.
- Branch by default — create a
projects/{project_id}branch in Phase 0. Extended work onmaincauses merge pain and risks conflicting with other contributors. If the user explicitly prefersmain, respect that. - Never skip the plan-review checkpoint — after writing
RESEARCH_PLAN.md, STOP. Do not write or execute analysis notebooks until the user explicitly chooses (a) Approve. This is the most important rule and the easiest to violate. Nothing enforces it: no hook refuses the write, so keeping the checkpoint is on you. What does happen is that analysis code written under an unapproved plan is recorded toprojects/<id>/plan_deviations.jsonland read back at review and submit time. The checkpoint itself is owned and run by/research-plan(step 8); this rule is the contract/execute-planrelies on before it begins. - Update the plan when reality changes — if analysis reveals something that changes the approach, update
RESEARCH_PLAN.mdRevision History before continuing. The plan is a contract; revisions are explicit, not silent. A material change (drop/add a hypothesis, move a decision threshold, abandon the discrimination strategy) demotesactive → proposedand re-runs the plan-review checkpoint —/execute-planowns this revision loop. - Drive the process forward between checkpoints — checkpoints are explicit pause-points (Plan Review, Results Review). Outside of those, keep moving — don't stop after every individual step asking permission.
- Document as you go — pitfalls live-captured to
projects/<id>/memories/pitfalls.mdvia/pitfall-capture; discoveries and performance notes drafted in REPORT.md## Discoveries/## Performance Notessections (extracted by/submitto per-project memories at approval). The centraldocs/{pitfalls,discoveries,performance}.mdfiles are frozen historical archives — don't write to them. - Use Spark patterns from PROJECT.md —
get_spark_session(), PySpark-first,.toPandas()only for final small results. - Look up projects and prior work through the knowledge layer, not
projects/— useknowledge-context(beril context find/grep/pitfalls/discoveries/ls) for "what exists / what's known / related work" (Phase 1.8). If it's unavailable, say so and fall back to this checkout's files, noting recall is partial. Hand-readprojects/<id>/only for the project you're actively working in.
Critical Pitfalls (always mention)
Surface these early. Database-specific gotchas live in docs/pitfalls.md per-database H2 sections (frozen historical archive; grep -A 20 "^## <database_name>$" docs/pitfalls.md). Per-project pitfalls hit by recent projects on the same database family also live in projects/*/memories/pitfalls.md and are worth a scan. Universal pitfalls:
- Species IDs contain
--— This is fine inside quoted strings in SQL. Use exact equality (WHERE id = 's__Escherichia_coli--RS_GCF_000005845.2'), not LIKE patterns. - Large tables need filters — Some tables are very large (e.g.,
gene,genome_ani,reaction_similarity). Always filter by a partitioned/indexed column. Checkdocs/pitfalls.mdper-database section for the current list. - Annotation coverage varies — Some annotation tables (e.g., AlphaEarth embeddings) cover only a fraction of genomes. Check coverage with
COUNT(DISTINCT id)before relying on them. - Match Spark import to environment — On JupyterHub notebooks:
spark = get_spark_session()(no import). On JupyterHub CLI/scripts:from berdl_notebook_utils.setup_spark_session import get_spark_session. Locally:from get_spark_session import get_spark_session(requires.venv-berdl+ proxy chain). See.claude/skills/berdl-query/references/off-cluster-mechanics.mdfor off-cluster setup. - Auth token — stored in
.envasKBASE_AUTH_TOKEN(notKB_AUTH_TOKEN). - String-typed numeric columns — Some databases store numbers as strings. Always CAST before comparisons; check
docs/pitfalls.mdper-database section. - Gene clusters are species-specific — Cannot compare cluster IDs across species. Use COG/KEGG/PFAM for cross-species comparisons.
- Avoid unnecessary
.toPandas()—.toPandas()pulls all data to the driver node and can be very slow or cause OOM errors. Use PySpark DataFrame operations for filtering, joins, and aggregations. Only convert to pandas for final small results (plotting, CSV export).
Templates
RESEARCH_PLAN.md
The enriched, pre-registered RESEARCH_PLAN.md template (competing hypotheses, per-hypothesis falsification tests and decision criteria, discrimination strategy, confidence prior, feasibility verdict, per-notebook analysis plan) lives in the /research-plan skill, which owns plan authoring. See .claude/skills/research-plan/SKILL.md.
README.md
# {Title}
## Research Question
{Refined question}
## Status
In Progress — research plan created, awaiting analysis.
## Overview
{One-paragraph summary of the hypothesis and approach}
## Quick Links
- [Research Plan](RESEARCH_PLAN.md) — hypothesis, approach, query strategy
- [Report](REPORT.md) — findings, interpretation, supporting evidence
## Reproduction
*TBD — add prerequisites and step-by-step instructions after analysis is complete.*
## Authors
{Authors}
beril.yaml (project manifest)
project_id: {project_id}
status: exploration # exploration | proposed | active | analysis | reviewed | complete
created_at: "{ISO 8601 timestamp}"
last_session_at: "{ISO 8601 timestamp}"
branch: projects/{project_id}
engine:
name: {agent name, e.g. claude}
authors:
- name: "{author name}"
affiliation: "{affiliation}"
orcid: "{ORCID}"
artifacts:
readme: false
research_plan: false
report: false
review: false
Status transitions: exploration (project scaffolded, no plan yet) → proposed (RESEARCH_PLAN.md written) → active (notebooks started) → analysis (REPORT.md written; set by /synthesize) → reviewed (a REVIEW_N.md covers the current REPORT.md; set by /berdl-review) → complete (user approved and /submit recorded the approval). Upload outcome is tracked separately via the SUBMITTED.md / SUBMISSION_FAILED.md marker files in the project directory. Downstream skills gate on status: /submit requires reviewed (or already-complete for retries); /synthesize requires active for the forward path (and demotes reviewed silently or complete with confirmation when re-run). Update artifacts flags as each file is created. Update last_session_at whenever resuming work. The full audit trail of approvals and uploads lives in beril.yaml.approval, beril.yaml.previous_approvals, and beril.yaml.submissions[].