Skip to content

Agents: homeSpec.agents.claude.autoMode for auto mode rules - #57

Merged
andrewthomaslee merged 1 commit into
mainfrom
claude-auto-mode
Nov 29, 2026
Merged

andrewthomaslee merged 1 commit into
mainfrom
claude-auto-mode

Conversation

@andrewthomaslee

Copy link
Copy Markdown
Member

What

  • flake-parts/homeModules/agents/agents.nix: new homeSpec.agents.claude.autoMode with environment, allow, softDeny, hardDeny (string lists) and includeDefaults (default true). Rendered into ~/.claude/settings.json as autoMode.{environment,allow,soft_deny,hard_deny}. Only non-empty lists are written, each led by "$defaults".
  • tests/fixtures/nixos.nix: alice sets two rules.
  • tests/flake-module.nix: agents-wiring asserts the rendering, the $defaults lead and that empty lists are left out.

Why

  • /auto-mode-setup writes to user settings, which home-manager owns read-only. The rules have to come from Nix.
  • claude.settings is merged with recursiveUpdate, which replaces lists. Typed list options let several modules add rules.
  • Schema checked against claude-code 2.1.325: string lists, "$defaults" keeps the built-in rules, and autoMode is read from user, flag and policy settings only (not a project's .claude/).

Checks

  • fmt: 0 changed.
  • check: all checks passed (x86_64-linux), incl. agents-wiring. One existing warning (stdenv.isDarwin deprecated), unrelated.

Merge order

  1. This PR.
  2. external-systems/home: bump modules and set the rules for netsa.

🤖 Generated with Claude Code

Auto mode reads autoMode.{environment,allow,soft_deny,hard_deny} from
user settings, which home-manager owns read-only. claude.settings is
merged with recursiveUpdate, which replaces lists, so typed list options
let several modules add rules. Every non-empty list starts with
"$defaults" so claude's built-in rules stay in force.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@andrewthomaslee
andrewthomaslee enabled auto-merge (squash) November 29, 2026 14:18
@andrewthomaslee
andrewthomaslee merged commit 6e6a669 into main Nov 29, 2026
3 checks passed
andrewthomaslee added a commit to external-systems/home that referenced this pull request Nov 29, 2026
## What
- `users/netsa/claude-auto-mode.nix` (new): the org's auto mode rules
through `homeSpec.agents.claude.autoMode`, imported by netsa's profile.
- Environment (14): the org and its repos, private repos (`secrets`,
`gitops`), primary use, org CLIs (incl. `uv`, `hcloud`), Hetzner Robot,
Hetzner Cloud and Cloudflare, trusted domains (`external.systems`,
`clan.lol`), secrets handling, protected `main`, the worktree routine,
deploy targets, host containment, protected IaC.
  - Allow (1): pushing feature branches and `gh pr create/edit`.
- Soft block (6): deploys, `clan vars generate` on main, push or merge
to main, skipping hooks, disk wipes, Hetzner and Cloudflare changes.
  - Hard block (1): printing or writing a secret's value.
- `users/netsa/default.nix`: imports it.
- `flake.lock`: `modules` bumped to include external-systems/modules#57.
- `documentation/docs/machines/index.md`: the netsa row mentions the
rules.

## Why
`/auto-mode-setup` cannot write `~/.claude/settings.json` (read-only,
home-manager). The draft it produced was refined with the owner and
moved into Nix. Every list keeps claude's built-in rules (`$defaults`)
first.

## Checks
- `fmt`: 0 changed.
- `check`: all checks passed; `clan vars check` passed for every
machine. One existing warning (`stdenv.isDarwin` deprecated), unrelated.
- Rendered `settings.json` for netsa on kamrui-h1: `autoMode` has
environment, allow, soft_deny and hard_deny, each led by `$defaults`.

## Merge order
external-systems/modules#57 (merged), then this PR. Deploy afterwards
(owner): `clan machines update kamrui-h1` (and other machines with
netsa).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@andrewthomaslee
andrewthomaslee deleted the claude-auto-mode branch November 29, 2026 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant