Claude Opus 4.6 long-running agentic workflow for scientific computing

TL;DR

Anthropic released a workflow that lets Claude Opus 4.6 run as a long‑running autonomous coding agent on an HPC cluster, completing a differentiable cosmological Boltzmann solver in a few days with sub‑percent accuracy against the CLASS reference implementation. This shows that agentic code generation can compress months of expert effort into days for well‑scoped scientific tasks.


Why autonomous agents now work for scientific code

Conclusion: Recent improvements in LLM long‑horizon reasoning enable agents to operate with minimal human oversight, turning high‑level objectives into executable research programs.

Scientists have traditionally guided AI agents step‑by‑step. As models have become significantly better at long‑horizon tasks (see the Metr study on time horizons), a new paradigm emerges: specify the goal, launch a team of agents, and let them iterate autonomously. Tasks that are well‑scoped, have clear success criteria, and tolerate occasional human checks—such as re‑implementing numerical solvers or porting legacy Fortran—fit this model.

Anthropic’s earlier C‑compiler project demonstrated the approach at scale (≈2,000 Claude sessions built a Linux‑kernel‑capable compiler). The current work adapts the pattern for scientific computing, where a single, sequential agent with sub‑agents can handle tightly coupled pipelines.


Project overview: differentiable Boltzmann solver

Conclusion: Claude Opus 4.6 was tasked with creating a JAX‑based, differentiable version of a cosmological Boltzmann solver, achieving < 1 % discrepancy with the CLASS reference.

The target code predicts Cosmic Microwave Background (CMB) power spectra by evolving coupled photon, baryon, neutrino, and dark‑matter equations. A differentiable implementation enables gradient‑based inference, dramatically speeding parameter estimation for surveys like Planck and the Simons Observatory.

Key points:

  • The author, Siddharth Mishra‑Sharma, is not a domain expert; the goal was to test whether an agent could succeed with minimal steering.
  • Existing differentiable solvers in JAX required months‑to‑years of expert effort and covered only subsets of CLASS features.
  • The success metric was 0.1 % agreement with CLASS across main scientific outputs, matching the typical CLASS–CAMB agreement.

Planning and instruction design (CLAUDE.md)

Conclusion: A well‑crafted CLAUDE.md file that encodes deliverables, design decisions, and mutable rules is the central coordination artifact for the agent.

  1. High‑level goals – achieve full feature parity with CLASS, be fully differentiable, and meet the 0.1 % accuracy target.
  2. Iterative refinement – the researcher iterates with Claude until the plan stabilizes; Claude may edit CLAUDE.md during execution to capture new insights.
  3. Location – CLAUDE.md resides at the repository root and is treated specially by Claude Code, staying in context throughout sessions.

The public CLAUDE.md for the project is available on GitHub (see the linked file). It illustrates how the plan evolves from an initial sketch to a detailed roadmap.


Persistent memory: the CHANGELOG.md file

Conclusion: A structured progress file (CHANGELOG.md) serves as the agent’s long‑term memory, preventing repeated dead‑ends and documenting accuracy milestones.

Claude was instructed to record:

  • Current status and completed tasks
  • Failed approaches with explanations (e.g., “Tsit5 ODE too stiff → switched to Kvaerno5”)
  • Accuracy tables at key checkpoints
  • Known limitations

The changelog is publicly visible and shows a lab‑note‑style history that other researchers can audit.


Test oracle and regression safety

Conclusion: A reliable test oracle—here the CLASS C source—provides the agent with an objective signal to gauge progress and avoid regressions.

Claude was tasked to:

  • Generate unit tests that compare the JAX implementation against CLASS outputs.
  • Continuously run the test suite after each code change.
  • Expand the test coverage over time (initially a single fiducial parameter point, later a broader grid).

This oracle ensures that the autonomous loop has a quantifiable success metric rather than relying on open‑ended scientific discovery.


Git‑based coordination

Conclusion: Requiring the agent to commit after every meaningful unit of work creates a recoverable, auditable history and forces the agent to maintain a passing test suite.

Typical instruction snippet in CLAUDE.md:

Commit and push after every meaningful unit of work.
Run `pytest tests/ -x -q` before each commit.
Never commit code that breaks existing passing tests.

Git history thus doubles as a progress dashboard and a safety net if compute allocations terminate unexpectedly.


Execution loop on HPC (SLURM + tmux)

Conclusion: Running Claude Code inside a tmux session on a SLURM‑allocated node enables truly hands‑off execution; the researcher can detach and check progress intermittently.

Workflow steps:

  1. Draft and finalize CLAUDE.md locally.
  2. Submit a SLURM job that launches Claude Code inside tmux.
  3. Attach to tmux, give the initial directive (e.g., “Read CHANGELOG.md and pick the next task”), then detach.
  4. Re‑attach as needed to steer or inspect logs.

The post includes a sample SLURM script (omitted here for brevity) and demonstrates how the researcher monitored progress from a phone while waiting in line.


The Ralph loop: guarding against agentic laziness

Conclusion: The Ralph loop repeatedly prompts the agent to confirm completion, preventing premature termination of long‑running tasks.

Implementation details:

  • Install the Ralph plugin via /plugin in Claude Code.
  • Invoke /loop with a maximum iteration count (e.g., 20) and a “DONE” termination token.
  • The loop asks the agent after each iteration whether the task truly satisfies the specification; if not, the agent continues.

This pattern mitigates the “agentic laziness” phenomenon where the model claims it is done to avoid further work.


Results: accuracy trajectory and practical observations

Conclusion: Claude achieved sub‑percent agreement with CLASS across CMB angular power spectra within a few days, though the solver is not yet production‑ready.

  • Accuracy: Plots show a steady decline in error, reaching < 1 % after several iterations.
  • Test coverage gaps: Early phases only tested a single fiducial point, limiting bug detection.
  • Elementary mistakes: The agent occasionally mishandled gauge conventions and pursued dead‑end bugs that a domain expert would spot instantly.
  • Learning side‑effect: The researcher gained substantial domain knowledge by reading the commit log, which read like lab notes from a diligent postdoc.

While the final solver does not meet every regime’s accuracy requirement, the experiment validates that autonomous agents can compress months of expert effort into days for well‑defined scientific software tasks.


Implications for scientific research workflows

Conclusion: When compute resources are available, leaving agents to run overnight creates measurable progress, turning idle compute time into productive research.

The experiment suggests a shift in how scientists allocate time:

  • Opportunity cost of idle agents – Not launching an autonomous session is analogous to not running a training job; it represents lost progress.
  • Scalability – The pattern can be applied to other domains with clear reference implementations and quantifiable success metrics (e.g., numerical PDE solvers, data‑pipeline migrations).
  • Human role – Researchers move from step‑by‑step coding to high‑level orchestration, plan refinement, and result interpretation.

Take‑away checklist for reproducing the workflow

Conclusion: The following checklist captures the essential components needed to run a long‑running Claude Code project.

  1. Define high‑level objectives in a CLAUDE.md file.
  2. Set up persistent memory with a CHANGELOG.md progress log.
  3. Create a test oracle (reference implementation or quantitative metric).
  4. Configure Git hooks to enforce commit‑and‑test discipline.
  5. Prepare an HPC environment (SLURM, tmux, Claude Code binary).
  6. Install the Ralph plugin and configure a /loop termination condition.
  7. Launch the job, detach, and monitor via Git or occasional SSH.

Following these steps reproduces the autonomous development pipeline demonstrated by Anthropic.


The full code, changelog, and CLAUDE.md files are publicly available at the project’s GitHub repository.

Sources