Last week my agent's session started with a warning I didn't expect. Two config files had changed and I hadn't touched either one. That's exactly what I built config-guard for.
It started with an X thread. Arbit Chen pointed out that Postman 12.33.4 quietly added a plugin, a startup hook and a remote tool server to people's Claude Code and Codex setups on upgrade. I said I read anything that lands in those folders before I trust it. They asked the question I couldn't answer: does your guard catch what gets written there between sessions, or only what fires on tool calls? Only tool calls. So I built the other half, and the credit for the idea is theirs.
It's about 55 lines of Node.js with no dependencies. At the start of every session it asks one question: did any of the files that steer my agent change since I last looked?
Update, Nov 12
A reply on the X thread asked if it covers hooks shipped inside plugins. It didn't. It hashed the plugin list, which records version and commit, so an upgrade showed up as CHANGED. But I wouldn't have known a hook was added.
I fixed it the same day. It now also hashes the hooks, manifest and tool server files inside each installed plugin, found through the install paths in the plugin list. A test run flagged 23 plugin files as NEW. Plugin upgrades will be noisier now. I'd rather see that than miss a hook.
Why config is the soft spot
Most agent security talk is about the prompt. I worry more about the config, because nobody watches it.
- Hooks are code that runs on its own. One new line in the settings file and a command runs every session. I wrote about the good side of that in hooks that stop mistakes. It cuts both ways.
- The rules file gets read as instructions. Edit it and the agent follows the new rules without saying a word.
- Plugins and skills are code I didn't write, and they update themselves. A new version of something I trust is still new code.
- Every tool server I add is a new door.
None of that needs an attacker. A tool can rewrite these files on its own, and I forget my own changes. The tripwire doesn't decide which it was. It makes sure I look.
What it does
- It hashes the files that matter: settings, the rules file, keybindings, the status line script, every hook, every skill, the plugin and marketplace lists, and the tool server definitions. It also hashes the hooks, manifest and tool server files inside each installed plugin, since an upgrade can add a hook there without touching my settings.
- It compares them to a saved baseline, which is just file names and hashes from the last time I said everything looked right.
- It prints NEW, CHANGED or REMOVED next to a path. Names only, never contents, so a config with a token in it can't leak through the report.
- It keeps reporting until I accept. No going quiet after the first warning. One command saves a new baseline.
The script, simplified
This is the core. The real one watches more paths and handles a few quirks, but the idea fits on a page.
// config-guard.js: SessionStart check for changed agent config
// Hashes only. Never prints file contents.
const fs = require("fs"), path = require("path"), crypto = require("crypto");
const home = require("os").homedir(), base = path.join(home, ".claude");
const baseline = path.join(base, "state", "config-baseline.json");
const sha = (b) => crypto.createHash("sha256").update(b).digest("hex");
const watch = ["settings.json", "CLAUDE.md", "hooks", "skills",
"plugins/installed_plugins.json"];
const files = [];
const walk = (p) => {
let st; try { st = fs.statSync(p); } catch { return; }
st.isDirectory() ? fs.readdirSync(p).forEach((f) => walk(path.join(p, f)))
: files.push(p);
};
watch.forEach((f) => walk(path.join(base, f)));
const now = {};
for (const f of files) now[f] = sha(fs.readFileSync(f));
if (process.argv.includes("--accept") || !fs.existsSync(baseline)) {
fs.mkdirSync(path.dirname(baseline), { recursive: true });
fs.writeFileSync(baseline, JSON.stringify(now));
console.log("config-guard: baseline saved");
process.exit(0);
}
const old = JSON.parse(fs.readFileSync(baseline, "utf8")), out = [];
for (const k in now) if (!(k in old)) out.push("NEW " + k); else if (old[k] !== now[k]) out.push("CHANGED " + k);
for (const k in old) if (!(k in now)) out.push("REMOVED " + k);
if (out.length) {
console.log("config-guard: " + out.length + " change(s). Tell the user, names only, before trusting them:");
out.forEach((l) => console.log(" " + l));
}
How the warning reaches the agent
A SessionStart hook runs the script, and whatever it prints goes into the agent's context before I type anything. So the warning isn't a log I'll never open. The agent reads it first and tells me.
{
"hooks": {
"SessionStart": [
{ "hooks": [{ "type": "command",
"command": "node ~/.claude/hooks/config-guard.js" }] }
]
}
}
In my rules file I wrote what I want it to do: name the files that changed, names only, and wait for me.
What it caught
That session started with two changes, the plugin list and the marketplace list. I hadn't installed or updated anything, so I had the agent read the names and dates only. One official plugin had updated itself a few minutes earlier, and two official marketplaces had refreshed in the same minute. Nothing from a source I didn't know. I accepted the baseline.
The part I liked: the agent tried to run the accept command and the permission layer stopped it. Saving a baseline is a security call, so it only went through after I said yes in chat. The tool watching my config wouldn't let the agent approve its own changes.
What it won't do
- It catches change, not intent. A hash says a file is different, not whether the new version is good. I still have to look, and updates make some noise.
- The baseline sits next to the thing it guards. Anyone who can edit my config can rewrite the baseline too. It catches surprises and sloppy tools, not someone who already owns my account. If that matters to you, keep a copy somewhere the agent can't write.
- It only runs at session start, so a change mid-session waits for the next one.
- It only watches what I list. A new place that holds config goes unwatched until I add it.
Build your own
- List the files that change what your agent can do or is told to do: settings, rules, hooks, skills, plugin lists, tool server definitions. Skip the noisy ones.
- Hash them and compare to a baseline file. Print names, never contents.
- Keep the baseline outside the folders you watch.
- Run it from a SessionStart hook so the output lands in the agent's context.
- Tell the agent in your rules file what to do with a warning: report the names, don't trust the change, wait for you.
- Give yourself one accept command, and make it one the agent has to ask you about.
Start with just your settings file and your rules file. You'll know within a week if it earns more.
