Home→Glossary→Lock File

Lock File

Lock File

A marker claiming a task so two agents don't collide on the same work

✓ Runtime & Session
Talk to AY Automate ↗
File-based mutexCreated before work, removed afterReclaimable if stale

What is a Lock File

A lock file is a simple marker, often nothing more than a file named after the task it claims, that an agent creates before it starts work and removes once it finishes. Any other agent checking whether a task is available checks for that file first. If it exists, the task is already claimed, and a disciplined agent picks something else instead of working the same task in parallel.

This is a low-tech but reliable coordination mechanism precisely because it doesn't require any shared context or live communication between agents, it only requires that everyone checks the same shared directory before starting and after finishing. It is the same idea as a mutex in concurrent programming, applied at the level of files instead of memory.

A lock file is not foolproof, an agent that crashes mid-task can leave a stale lock behind, which is why most setups treat a lock older than some threshold, commonly a day, as reclaimable rather than permanent. The lock's value is in the normal case, preventing accidental collisions, not in guaranteeing correctness against every possible failure.

AY Automate

Build your own agent skills, not just prompts.

We design, build, and ship the Claude Code skill libraries production teams actually run on.

Talk to AY Automate ↗

Key properties

✓Created before any work starts, not after
✓Removed once the task finishes, freeing it for others
✓A stale lock can usually be reclaimed after a defined timeout