---
title: "Test a local patch · airgap"
description: "Test an uncommitted patch with airgap_verify_patch: the diff is applied to clean base files inside a microVM and the tests run there."
url: https://www.useairgap.dev/guides/verify-patch
---

[All guides](https://www.useairgap.dev/guides)

# Test a local patch

Test an uncommitted patch with airgap_verify_patch: the diff is applied to clean base files inside a microVM and the tests run there.

## Test a local patch

**Short answer:** Use `airgap_verify_patch` when you have an uncommitted unified diff on your machine that is not on GitHub yet. Your agent supplies the clean base files and the unified diff; airgap uploads that snapshot to a disposable Linux microVM, checks and applies the patch with `git apply`, runs your test command, scrubs secrets from the logs, and destroys the VM.

> `use airgap to verify this patch before I commit it`

> `apply this diff to our base files in airgap and run pytest`

### How patch verification isolates your working tree

airgap never reads your local repository or working tree on its own. Because a diff alone cannot reconstruct a project, the caller explicitly sends only the clean base files needed to build and test. Inside the remote `/workspace` directory, airgap runs:

1. **Path validation:** Rejects absolute paths, path traversal (`..`), Windows drive prefixes, control characters, symlinks, and `.git` metadata. Files are uploaded as regular UTF-8 files (mode `0644`).
2. **Dry-run and apply:** Runs `git apply --check` before `git apply` so a broken or stale patch fails cleanly without running tests against partial files.
3. **Test execution and summary parsing:** Runs your `test_command` with a bounded timeout, redacts secrets from output, and hashes the request, base snapshot, and result into an unsigned SHA-256 receipt.

### Inputs and limits

| Field / Limit | Value | Notes |
| --- | --- | --- |
| `diff` | Required string | Standard unified diff applied with git apply |
| `test_command` | Required string | Shell command that builds and executes tests |
| `files` | Required object | Map of relative file path to UTF-8 base file content |
| `image` | Auto-detected | Image must provide sh, tar, mkdir, sleep, and git |
| `timeout_secs` | 120 s (1..1800 s) | Plus up to 600 s for first-time template provisioning |
| Snapshot cap | 2000 files / 8 MiB | Total path + content bytes; upload only minimal files needed |

### Direct MCP tool call

```
{
  "tool": "airgap_verify_patch",
  "arguments": {
    "diff": "--- a/src/lib.rs\n+++ b/src/lib.rs\n@@ -1 +1 @@\n-pub fn add(a: i32, b: i32) -> i32 { a - b }\n+pub fn add(a: i32, b: i32) -> i32 { a + b }\n",
    "test_command": "cargo test --quiet",
    "files": {
      "Cargo.toml": "[package]\nname = \"demo\"\nversion = \"0.1.0\"\nedition = \"2021\"\n",
      "src/lib.rs": "pub fn add(a: i32, b: i32) -> i32 { a - b }\n#[test] fn ok() { assert_eq!(add(2, 2), 4); }\n"
    }
  }
}
```

### Verification rules and troubleshooting

`verified: true` requires exit code `0`, untruncated logs, a recognized Rust or pytest test summary, at least one passing test, and zero failures. If your stack prints an unrecognized test summary format, airgap returns `command_passed: true` with null counts and `verified: false` rather than guessing. For GitHub pull requests, prefer [Verify a pull request](https://www.useairgap.dev/guides/verify-pr) so you never have to serialize files manually.

## Keep reading

[All 12 guides](https://www.useairgap.dev/guides)

### [Run tests or a one-off command](https://www.useairgap.dev/guides/run)

The image is picked from your files. The VM is deleted after.

### [Act on untrusted issue text](https://www.useairgap.dev/guides/issue-text)

Scan issue bodies and comments before the agent acts on them.
