Overview
Let Claude Code edit a NixOS configuration kept in a Git repository and check that it builds, while you review every diff and run the command that activates the new system yourself.
Problem or Objective
More in Coding and Code Review
AI Agents and Models
Tools and Integrations
- Tools
- Claude Code · NixOS · Git
- Prerequisites
- Claude Code with a Claude plan or API key, a NixOS machine whose configuration lives in a Git repository, and console access in case a change breaks networking.
How It Works
Keep the machine's NixOS configuration in a Git repository and open Claude Code in it. Describe the change you want, such as adding a service or changing an option, and let it edit the files. Ask it to run only a step that builds or evaluates the configuration without activating it; check your NixOS manual for which rebuild command does that. Do not approve commands that activate the configuration or anything run with sudo. Read the diff and the build output, then commit and run the activation command yourself on the machine. For scripted runs with claude -p, list only the read, edit and build tools with --allowedTools and use the dontAsk permission mode, so every other call that would prompt is denied instead of waiting for you.
Implementation Workflow
Steps assembled from the agents, tools and prompt of this entry. Adapt them to your own setup.
- Choose the agentSet up Claude Code.
- Connect the toolsConnect the tools this workflow relies on: Claude Code, NixOS, Git.
- Check the prerequisitesClaude Code with a Claude plan or API key, a NixOS machine whose configuration lives in a Git repository, and console access in case a change breaks networking.
- Gather your detailsCollect what the prompt asks for: Change you want, Folder with this machine's configuration, Command that builds without activating.
- Run the starter promptPaste the starter prompt below into Claude Code and adapt it to your case.
- Check against the documentationCompare what you get with the documentation at code.claude.com before you rely on it.
Practical Starter Prompt: Propose a NixOS change and prove it builds
Fill the fields to adapt the prompt. Empty fields stay as visible [placeholders].
In this repository, make this change to the NixOS configuration: [Change you want]. Edit only files under [Folder with this machine's configuration]. When the edit is done, run [Command that builds without activating] to check that the configuration evaluates and builds, and fix any errors it reports. Do not run anything that activates the configuration, do not use sudo and do not commit. Finish by showing me the full diff and listing anything that could affect networking, SSH access or booting, so I can review it before I apply it myself.Read the diff and the build output yourself, then run the activation command on the machine. Keep sudo and activation out of every allow list.
Expected Results and Benefits
This is a suggested workflow, not a reported result. The points below are what the cited documentation says the tools can do.
This is a suggested workflow, not a reported outcome. Anthropic's documentation says Claude Code reads a codebase, edits files, runs commands and works directly with git, and that a claude -p run in dontAsk mode denies every call that would otherwise prompt. It says nothing about NixOS, so which commands only build and how to roll back a bad change come from the NixOS manual and your own testing.
Limitations and Considerations
The safety of this setup comes from the permission rules, so check them before every unattended run: in dontAsk mode Claude Code denies calls that would prompt, but the headless page notes that a mod you installed can still approve some of them, and --allowedTools entries or permissions.allow rules let listed calls through. Never pre-approve sudo or the activation command. A configuration that builds can still lock you out of a remote machine, for example through firewall or SSH changes, so keep console access and learn from the NixOS manual how to return to the previous configuration. Keep secrets out of the repository the agent reads. Results depend on your setup and were not independently reproduced by Top 200 Repos.
GitHub Repositories
AI Agent Repository
Source code of the agent that does the work.
Official Website
The official site of the main tool or project in this use case.
Visit Website (opens in a new tab)code.claude.com
Related Videos
About anthropics/claude-code
The SECRET Claude Code Upgrade That Has Everyone Going Nuts (Full Guide) (opens in a new tab)
The title names the project, the description links the project website.
Watch on YouTube (opens in a new tab)About anthropics/claude-code
The only Claude Code guide you'll ever need (Opus 4.5) (opens in a new tab)
The title names the project, the description links the project website.
Watch on YouTube (opens in a new tab)Independent creators. Listing a video implies no endorsement, sponsorship or partnership.
Sources
- Overview - Claude Code Docs (opens in a new tab)
Project documentation · code.claude.com · Undated · Source checked 25 Nov 2026, 11:57 UTC
What this source supports
- Claude Code is an agentic coding tool that reads your codebase, edits files, runs commands, and integrates with your development tools.
- Claude Code works directly with git: it stages changes, writes commit messages, creates branches and opens pull requests.
- Run Claude Code programmatically - Claude Code Docs (opens in a new tab)
Project documentation · code.claude.com · Undated · Source checked 26 Nov 2026, 17:27 UTC
What this source supports
- claude -p runs Claude Code non-interactively, and --allowedTools lets the listed tools run without asking for permission.
- In a Manual mode claude -p run, a call that needs approval is denied unless something approves it, such as a PermissionRequest hook.
- In dontAsk mode Claude Code denies every call that would otherwise prompt, though a mod you installed can still approve some of those calls.

