Skip to content

feat(profile): freeze the files an agent runs as its tools (MCP code mode) - #997

Merged
sandstream merged 1 commit into
mainfrom
claude/web-kit-status-sync-p6fg9a-profile-code-tools
Nov 23, 2026
Merged

sandstream merged 1 commit into
mainfrom
claude/web-kit-status-sync-p6fg9a-profile-code-tools

Conversation

@sandstream

Copy link
Copy Markdown
Owner

Owner decision from kit-research mcp-code-mode-vs-kit: yes.

Why

With MCP "code mode" (Anthropic's code execution with MCP), the agent sees each MCP tool as a file it calls from code, for example servers/salesforce/updateRecord.ts, and it may save working code under skills/ for its next run. Those files are the tool definitions. An edit to updateRecord.ts that sends the record elsewhere changes what the tool does, and no gate sees a tool call for it. kit profile recorded skills, MCP servers, plugins and (since #986) hooks, but not these files.

What

The operator lists the globs in .kit-profile.toml:

code_tool_paths = ["servers/**", "skills/**"]
  • kit profile freeze keeps the globs (operator-authored, like scope) and records [[code_tools]]: each matching file's POSIX path and the first 16 hex digits of its SHA-256. The summary line adds "3 code tool file(s)".
  • kit profile check compares them like the other kinds, under a code tools heading: an edited wrapper is version drift, a new file is ADDED, a deleted one REMOVED. --gate fails on them.
  • Files are walked, not read from git, so an uncommitted file the agent just saved is found. .git and node_modules are skipped, symbolic links are not followed, at most 2,000 files.
  • No globs declared: nothing changes. Globs declared after the last freeze: "code tools: present, but this profile was frozen before kit recorded them; run kit profile freeze. Not judged."

kit does not guess the globs. A servers/ directory is just as often application code, and freezing it by default would turn every commit into drift.

The glob matcher is globToRegExp from src/adr.ts (imported, not changed).

Compatibility

An older kit rejects a profile that holds code_tool_paths or code_tools (the schema is strict), as it does for hooks since #986.

Verification

  • src/profile/code-tools.test.ts: nine tests, one through the real CLI: freeze three files, check --gate passes, edit the Salesforce wrapper, check --gate fails naming it.
  • contracts/kit.opencli.json regenerated for the help text.
  • node scripts/prepush.mjs: build, format, lint, tests of the changed files, self-audit pass; kit adr check passes. kit review and the new-source-file check fail locally for container reasons. Semgrep did not run (not installed here).
  • No protected path. Harness-neutral: the files are the same whichever agent runs them.

Generated by Claude Code

…mode)

In code mode the agent calls MCP servers through generated files and
saves code as skills for its next run; an edit to one changes a tool
without any call a gate sees. Operator-declared globs in
.kit-profile.toml (code_tool_paths); freeze hashes the matching files
and check reports a file added, removed or changed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DbF4MFePXWNCd4dxBQvqH2
@github-actions

Copy link
Copy Markdown

Docker image built, scanned, and smoke-tested in CI. The PR image is local to this run and is not published.

@sandstream-kit-reviewer sandstream-kit-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kit review gate at e6eb512a0028: gates passed. All 33 checks passed on this commit, no file is in a protected class, 8 files and 304 lines changed. This approval is deterministic; it does not judge what the change is for.

@sandstream
sandstream merged commit abc0faa into main Nov 23, 2026
33 checks passed
@sandstream
sandstream deleted the claude/web-kit-status-sync-p6fg9a-profile-code-tools branch November 23, 2026 23:26
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.

2 participants