Skip to main content

Passive execution tracing for file and package changes.

Project description

ExecDiff

See what AI-generated code will change before running it.


Problem

AI coding tools and agents today can:

  • install dependencies
  • create files
  • modify configs
  • run migrations
  • delete project files

All automatically.

When something breaks after execution, tools cannot answer:

What exactly changed because of this action?

Git tracks source code changes —
but it does not track execution side effects like:

  • newly installed Python packages
  • runtime-created files
  • deleted files
  • modified configs

So tools often fall back to:

regenerate and try again


Solution

ExecDiff allows tools to run AI-generated code and observe:

what changed in the workspace because of that execution

It detects:

  • files created
  • files modified
  • files deleted
  • Python packages installed

inside a specific workspace
during a specific execution window.


Installation

pip install execdiff

Example

Create a test script:

import execdiff
import json
import os

os.makedirs("workspace", exist_ok=True)

diff = execdiff.run_traced(
    "touch workspace/test.txt",
    workspace="workspace"
)

print(json.dumps(diff, indent=2))

Run:

python test.py

API Reference

start_action_trace(workspace=".")

Start tracing a workspace for changes. Must be called before any operations.

import execdiff

execdiff.start_action_trace(workspace="./my_workspace")
# ... your code that makes changes ...

stop_action_trace()

Stop tracing and return a diff of all changes detected. Automatically logs to .execdiff/logs/actions.jsonl.

diff = execdiff.stop_action_trace()
# Returns: {"files": {...}, "packages": {...}}

last_action_summary(workspace=".")

Get a human-readable summary of the last action trace without parsing JSON.

summary = execdiff.last_action_summary(workspace=".")
print(summary)

Output example:

Last AI Action:

Created:
- output.txt
- data.json

Installed:
- requests==2.32.0

snapshot_workspace_state(workspace)

Take a full metadata snapshot of the workspace (files with mtime/size, installed packages).

state = execdiff.snapshot_workspace_state(workspace=".")
# Returns: {"files": {...}, "packages": {...}}

Output Format

Diff Structure

{
  "files": {
    "created": [{"path": "file.txt", "mtime": 123.45, "size": 1024}],
    "modified": [{"path": "config.yaml", "before_mtime": 123, "after_mtime": 124, "before_size": 512, "after_size": 1024}],
    "deleted": [{"path": "old_file.txt", "mtime": 123.45, "size": 256}]
  },
  "packages": {
    "installed": [{"name": "requests", "version": "2.32.0"}],
    "upgraded": [{"name": "django", "before_version": "3.2", "after_version": "4.0"}],
    "removed": [{"name": "deprecated_lib", "version": "1.0"}]
  }
}

Log File

All action traces are automatically persisted to .execdiff/logs/actions.jsonl:

{
  "timestamp": "2026-02-18T18:19:35.872838",
  "workspace": "/path/to/workspace",
  "diff": {...}
}

Use Cases

ExecDiff can help AI coding tools:

  • preview changes before applying generated code
  • detect unintended file or dependency changes
  • explain execution impact to users
  • debug failed automation
  • build undo / rollback systems

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

execdiff-0.0.5.tar.gz (16.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

execdiff-0.0.5-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

Details for the file execdiff-0.0.5.tar.gz.

File metadata

  • Download URL: execdiff-0.0.5.tar.gz
  • Upload date:
  • Size: 16.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for execdiff-0.0.5.tar.gz
Algorithm Hash digest
SHA256 5a432426b9b3b7a6b436aefcf8a85510d4e573e32ce8c9c79b4957bde662310e
MD5 fb72bcd51674d3c0fa22afbd6e13e1db
BLAKE2b-256 618d970e85d0963e8013642e8e333b77e9ee31b47a087eaaf73f8af94d2ad92b

See more details on using hashes here.

File details

Details for the file execdiff-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: execdiff-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 14.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for execdiff-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 f16875e73f32d5c33c6b3c0f36fe19b7bad21399fad7d561dc3a52360aa35c26
MD5 eebd32d7c841a509eef5fee22279ca4e
BLAKE2b-256 b894a235340eccf93945d3314b2effb14d8b4dd042387e74905275f4afb78fa8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page