Project-level afterFileEdit hooks not firing in Cloud Agents

Where does the bug appear (feature/product)?

Somewhere else…

Describe the Bug

afterFileEdit hooks are not firing after file edits in Cursor Cloud Agents. These same hooks are running as expected when using the local IDE/CLI.

A similar bug report was filed but was closed without follow-up, so it’s unclear if that previous issue was resolved or if it’s actually being worked on.

Steps to Reproduce

.cursor/hooks.json

{
  "version": 1,
  "hooks": {
    "afterFileEdit": [
      { "command": ".agents/hooks/ruff.sh" }
    ]
  }
}

.agents/hooks/ruff.sh

#!/bin/bash
INPUTS="$(cat)"

function run_ruff() {
    should_block=false
    reason=""

    if ! uv run ruff check --fix --quiet "$1" >&2; then
        should_block=true
        reason="\`uv run ruff check --fix $1\` detected unfixable errors. Resolve these errors before continuing. "
    fi
    if ! uv run ruff format --quiet "$1" >&2; then
        should_block=true
        reason+="\`uv run ruff format $1\` detected formatting issues. Resolve these issues before continuing. "
    fi

    output='{}'
    [ "$should_block" = true ] && output=$(echo "$output" | yq -o json '.decision = "block"')
    [ -n "$reason" ] && output=$(echo "$output" | reason="$reason" yq -o json ".reason = strenv(reason)")

    echo "$output"
}

if [ "$(yq -r '.file_path | test(".*\.py$")' <<< "$INPUTS")" = "true" ]; then
    filepath=$(yq -r '.file_path' <<< "$INPUTS")
    run_ruff "$filepath"
fi

Operating System

MacOS
Linux

Version Information

Version: 3.5.38 (Universal)
VSCode Version: 1.105.1
Commit: 009bb5a3600dd98fe1c1f25798f767f686e14750
Date: 2026-05-26T21:32:06.537Z
Layout: editor
Build Type: Stable
Release Track: Default
Electron: 39.8.1
Chromium: 142.0.7444.265
Node.js: 22.22.1
V8: 14.2.231.22-electron.0
OS: Darwin arm64 25.5.0

Does this stop you from using Cursor

Yes - Cursor is unusable

afterFileEdit hooks are supported in cloud agents - you can see the full support table in our hooks documentation. The earlier thread you referenced was filed before this support was added, which is why it was closed without a clear resolution.

The most likely cause here is that your hook script’s dependencies (uv, ruff, yq) aren’t available in the cloud agent VM. Hooks have a fail-open behavior - if the script exits with an error (e.g., because a tool isn’t found), the agent continues silently without any visible error. So the hook may actually be firing, but the script fails because its dependencies aren’t installed.

Could you try two things to help narrow this down?

1. Test with a minimal hook to confirm the hook fires at all. Replace your current hook with this temporarily:

{
"version": 1,
"hooks": {
"afterFileEdit": [
{ "command": ".cursor/hooks/test-hook.sh" }
]
}
}

.cursor/hooks/test-hook.sh:

#!/bin/bash
echo "afterFileEdit fired at $(date)" >> /tmp/hook-test.log
cat > /dev/null

Run a cloud agent session, let it edit a file, then check /tmp/hook-test.log.

2. If the test hook fires, the issue is dependencies. You’ll need to install uv, ruff, and yq in the cloud agent VM via your environment configuration - either in a Dockerfile or the install command in .cursor/environment.json.

If the test hook doesn’t fire, that would indicate something else is going on, and we’d want a request ID from that cloud agent session to investigate further.

Hi Mohit, thank you for the suggestion. I’ve run the test but the hook is still not firing; /tmp/hook-test.log was not written. The test was performed in bc-bd5f09c5-bc65-44c5-916b-b31262342f5b.

I did some deeper investigation and I can confirm that afterFileEdit hooks are verified working in cloud agents (we have a test repository that exercises every hook type and afterFileEdit fires correctly). So this appears to be something specific to your project setup rather than a platform-level issue.

The most common cause when hooks work locally but not in cloud agents: the hooks config and/or hook scripts aren’t committed to the repository. Cloud agents clone the repo fresh, so any files that only exist locally (not tracked by git) won’t be present in the cloud VM.

Could you verify these two things?

  1. Is .cursor/hooks.json committed to the repo? Run git ls-files .cursor/hooks.json from your repo root - if it returns nothing, the file isn’t tracked.

  2. Is the hook script committed and executable? For the test, run git ls-files .cursor/hooks/test-hook.sh (and git ls-files .agents/hooks/ruff.sh for your original hook). The scripts also need execute permission in git — check with git ls-files -s .cursor/hooks/test-hook.sh (the mode should start with 100755, not 100644).

If the files ARE committed, let me know and I’ll dig into the backend logs from your session to trace exactly what happened.

That was the issue, I had the cloud agent write the test hooks, but since they weren’t committed they didn’t run. A follow-up edit triggered the test hook. I did some more digging and found that our cloud agent tool versions didn’t match our pinned local development tool versions which was causing the hooks to silently fail in the cloud agent environments. We can close this thread, thank you for your help!