Enclawed Code: How Deterministic Security Layers Harden Claude Code Agent Execution An open-source project called Enclawed Code wraps the Claude Code CLI in a deterministic security layer that classifies every tool call as reversible or not before execution, running reversible actions in a sandbox and requiring approval for network calls, config changes, package installs and destructive file operations. A companion paper (DOI: 10.5281/zenodo.24524917) reports zero harmful actions passed and zero harmless actions blocked across 15,021 real tool calls, 7.7x fewer approval prompts than Claude Code's default permission mode, and 11 attacks from compromised hosts all blocked when paired with Enclaweder's hardware-backed attestation. Enclawed Code wraps Claude Code in a deterministic security layer that checks every action before execution. The core insight: stop asking the LLM to judge safety. Instead, enforce boundaries at the infrastructure layer using a fixed rule that asks one question: can this action be undone? The project ships as open source with a companion research paper showing zero harmful actions passed and zero harmless actions blocked across 15,021 real tool calls. It also claims 7.7x fewer approval prompts than Claude Code's default permission mode. Claude Code and similar agents execute shell commands, edit files, and call tools on your local machine. They read context along the way: README files, web pages, tool output. Anyone can plant instructions in those contexts. Traditional safeguards rely on the LLM to recognize malicious intent. This creates three failure modes: Enclawed Code moves the security boundary outside the model. It intercepts every action before execution and applies a deterministic rule. The LLM never sees the security decision. Enclawed Code runs as a wrapper around the standard Claude Code CLI. You type ecwcode instead of claude . The security layer sits between the agent's action planner and the host system. The sealed space is a sandboxed environment where read operations, read-only commands, file edits with automatic versioning , and tests execute without approval. | Action Type | Reversible? | Execution Path | |---|---|---| | File read | Yes | Runs in sealed space | | Read-only shell command | Yes | Runs in sealed space | | File edit | Yes | Runs after old version saved | | Test execution | Yes | Runs in isolated environment | | Network call | No | Requires approval | | System configuration change | No | Requires approval | | Package installation | No | Requires approval | | Destructive file operation | No | Requires approval | The reversibility rule is not configurable by the LLM. It is a fixed policy enforced at the infrastructure layer. Enclawed Code uses three mechanisms to enforce boundaries: Every tool call is parsed and classified before execution. The system extracts the operation type, target resources, and scope. This happens outside the LLM's control. python Conceptual flow not actual Enclawed Code source def intercept action action : parsed = parse tool call action if is reversible parsed : old state = snapshot affected resources parsed result = execute in sealed space action log action action, old state, result return result else: approval code = generate approval code user input = prompt user action, approval code if user input == approval code: result = execute with full privileges action log action action, None, result return result else: raise SecurityViolation "Action blocked by user" Reversible actions run in isolated environments. File system changes are copy-on-write. Network access is restricted. The sealed space is torn down after execution, but state changes like edited files are committed back to the host with full audit trails. When paired with Enclaweder, the security key unlock uses hardware-backed attestation. This prevents a compromised host from bypassing the approval flow. The research paper reports 11 attacks from compromised computers, all blocked with Enclaweder present. The companion paper DOI: 10.5281/zenodo.24524917 tested three Claude models across four permission modes with 4,350 live runs. Key findings: The benchmark does not test performance overhead. The paper focuses on security effectiveness, not latency. Enclawed Code is a local wrapper. It does not require cloud infrastructure or API changes. You install it on the same machine where you run Claude Code. This makes it suitable for: It is not suitable for: Enclawed Code preserves session state across security violations. If an action is blocked, the agent's conversation history, file snapshots, and sealed space state remain intact. The user can resume the session after reviewing the blocked action. This is critical for long-running sessions where a single blocked action should not discard hours of work. The current implementation logs every action, approval decision, and state snapshot. However, it does not expose metrics for: These gaps make it hard to predict performance impact in production. The fixed rule might incorrectly classify an action as reversible. For example, a file edit that triggers a build process with side effects like uploading artifacts would run without approval. Mitigation: The sealed space restricts network access, so most side effects are contained. But this is not foolproof. If the agent generates many irreversible actions, users still face approval prompts. The 7.7x reduction helps, but it does not eliminate the problem. Mitigation: Tune the agent's system prompt to prefer reversible operations. This is a prompt engineering task, not a security fix. Without Enclaweder, a compromised host can bypass the security layer. The approval prompt is just a UI element. An attacker with root access can modify the binary to skip checks. Mitigation: Deploy Enclaweder for hardware-backed attestation. This adds cost and complexity. Use Enclawed Code when: Avoid it when: The core idea is sound: move security decisions outside the LLM. The implementation is production-ready for local workflows but needs cloud deployment support and better observability before it scales to multi-tenant or high-throughput scenarios.