Files
slop-broker/AGENTS.md
T
jackos1998andClaude Opus 5.5 a565260021
CI / Check (pull_request) Canceled after 0s
CI / Check (push) Successful in 5m8s
docs: Release separately and keep notes in issues
The version is bumped in a release pull request once its changes have
merged, not in each change. Running notes go in Gitea issues instead
of a WIP file on a branch, which went stale.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-28 18:18:41 +00:00

7.7 KiB

AGENTS.md

This file provides guidance to coding agents working in this repository. CLAUDE.md is a symlink to it — edit AGENTS.md, not the symlink.

Prefer this file over agent memory. When you learn something durable about this repo — a convention, a workflow gotcha, a design rationale — record it here or in the doc under docs/ that owns the topic, not in agent memory. This file is versioned and shared; memory is not.

Keep this file lean: rules, workflows, safety constraints and sharp gotchas an agent needs before starting work. Design and rationale belong in docs/design.md, and how the code is put together in docs/architecture.md; link to them instead of repeating them.

Overview

slop-broker runs privileged operations (SSH commands, deploys, builds and age secrets, and later DNS and previews) for coding agents, under a policy and usually after a human approves each one. Agents use the slop CLI; approvers use slop-approve or the web app. It's a Rust crate (one library, the slop-broker and slop binaries) plus NixOS and home-manager modules, all in this flake.

Its reference deployment is nixfiles, which consumes this flake as an input; box-specific configuration (which box runs the broker, its policies, firewall, secrets and persistence) lives there, not here.

Commands

The development environment is devenv (devenv.nix): direnv with .envrc, which takes the devenv CLI from the flake's nixpkgs, or devenv shell (without direnv, nix shell --inputs-from . nixpkgs#devenv provides it). It has the Rust toolchain, the build's native inputs and git, and lists its scripts on entry. The flake doesn't need devenv: it has the package, modules, the demo's VMs and the checks. nix develop is a plainer alternative (devShells.default): the same toolchain, with the native inputs taken from the package, but none of devenv's scripts, devenv test or the demo's host side.

  • cargo build, cargo test — the unit and integration tests (tests/). tests/builder.rs needs git, which the devenv shell provides.
  • cargo clippy --all-targets — keep it free of warnings. devenv test runs clippy (warnings as errors) and the tests.
  • cargo fmt — the crate is formatted with rustfmt (rustfmt.toml); run it on code you change.
  • nix build — the package, which also runs the tests.
  • CI (.gitea/workflows/ci.yaml) runs nix flake check for pull requests and pushes to main: the package with its tests, clippy (warnings as errors), fmt (cargo fmt --check), shellcheck on src/**/*.sh and the VM test. Keep them passing. nix flake check --no-build fails where the VM test's keys haven't been built, because the test reads them at evaluation.
  • vm-test (or nix build -L .#checks.x86_64-linux.vm) — the NixOS VM test of the broker module (needs KVM).
  • The demo: devenv up -d starts the host side (the broker from this checkout, its web app, Pocket ID and the box VM); devenv processes logs <name> shows a process's output and devenv processes down stops them. demo boots the agents' VM on the terminal and holds it until poweroff, so an agent should run it in the background with stdin from a pipe it controls. slop-approve in the devenv shell answers requests, demo-box SSHes into the box VM, and demo-merge <branch> moves the demo repository's protected master. Stop the agents' VM with poweroff on its console or by stopping that background task, not with pkill -f, whose pattern also matches the shell running it.
  • nix fmt — formats Nix with nixpkgs-fmt. Ask before running it on a file you didn't write: some files aren't canonically formatted, and a whole-file reindent buries a logical change.

Nix only sees files Git tracks, so a new file must be added (jj does this when it snapshots; otherwise git add -N) before nix build can use it.

Conventions

  • Prefer jj for status, diffs, history, commits, rebases and remote operations; the repository is colocated, so Git tooling works too. Inspect jj status, jj diff and jj log before editing, preserve existing changes, and use explicit revisions when rewriting history.
  • Separate logical steps in code with blank lines, in every language and inside function bodies: a function that gathers its inputs, checks them, acts and reports should read as short paragraphs, not one block. Keep closely related statements together, and leave a blank line before a comment that introduces the next step.
  • Comment where it genuinely aids understanding, not for trivial code; match the existing, fairly sparse comment density. When adding something general, comment its general purpose, not the specific change or one-off reason it was introduced for.
  • Everything an approver sees comes from agents and must be treated as hostile: pass it through ops::printable (the web app's templates do both that and HTML escaping; never mark a value |safe). Never let request contents decide what runs beyond what the operation's typed fields allow.
  • Nix modules use plain lib.mkOption, options under services.* (NixOS) and programs.* (home-manager), and never reference a particular deployment. Runtime secrets are paths outside the Nix store, loaded with LoadCredential.
  • Commit subjects follow area: Capitalized summary (e.g. web: Show leases, nix: Add a cache option); aim for 50 characters and do not exceed 72. Hard-wrap commit bodies at 72 characters; -m preserves unwrapped text, so include literal line breaks or use a file. Check jj log --no-graph -r <revision> -T description and fix any line over 72 characters before reporting a commit. A short body with the rationale is welcome when the subject isn't enough. Co-Authored-By is the only trailer used here; don't add session or tooling trailers.
  • Keep logically distinct (unrelated) changes in separate commits, but one piece of work stays in one commit even when it touches code, modules and docs; split only when a reader would ask why two things arrived together.

Work in progress

Plans, status, next steps and handoffs go in Gitea issues on dev/slop-broker, one per piece of work with its description kept current, not in files in the repository or on branches. When the work is done, move what lasts into docs/ or this file and close the issue.

Writing

  • In prose and commit messages, quote code-like identifiers (commands, options, paths, crate and attribute names) in backticks.
  • Keep docs plain — avoid vague filler. Use "layout"/"structure" rather than "shape", and name things directly instead of reaching for umbrella words.
  • Use tables for lists of structured items, with the item's name as the link.
  • Break up long prose. A bullet or numbered step running past about three lines over several facts becomes a short lead (a bold phrase or one sentence) with nested bullets, a fact each; several such points on one topic become a ### subheading. A paragraph listing several facts becomes bullets or a table. Restructure a long bullet you're adding to rather than lengthening it.
  • Prefer durable concepts and named configuration identifiers over exact numbers that are tunable and likely to drift; describe those by purpose and point at their source.
  • Each fact has one home. Update the doc that owns a topic when the code changes it:
    • docs/design.md: what the broker does and why, for deployers and reviewers;
    • docs/architecture.md: where the code does it, for contributors. It links to the design for behaviour rather than restating it;
    • slop-tools.md: the agents' guide (update it with each new operation).