Reference
CLI commands, MCP tools, hooks, and configuration — generated from the same source code that powers the tools.
CLI
Install globally with npm i -g preclaim, then run any command below.
initFull setup — auth, project creation/join, and automatic agent detection + configuration
preclaim init$ preclaim initloginAuthenticate with Preclaim
preclaim login$ preclaim loginlockLock a file
preclaim lock <file>$ preclaim lock src/api/auth.ts --ttl 30unlockRelease a file lock
preclaim unlock [file]$ preclaim unlock src/api/auth.ts --forcestatusShow active locks for this project
preclaim status$ preclaim statuscheckCheck lock status for files
preclaim check <files...>$ preclaim check src/api/auth.ts src/lib/db.tswhoamiShow current user info
preclaim whoami$ preclaim whoamiconfigView or modify project configuration
preclaim config$ preclaim config --set ttl=30sessionsShow active sessions for this project
preclaim sessions$ preclaim sessionslogsShow recent lock activity for this project
preclaim logs$ preclaim logsinstall-hooksInstall Claude Code hooks in the current project
preclaim install-hooks$ preclaim install-hooksopenOpen the Preclaim dashboard in your browser
preclaim open$ preclaim openinfoShow project ID, backend URL, dashboard URL, config, and version
preclaim info$ preclaim infodoctorRun health checks: backend, credentials, hooks, heartbeat daemon
preclaim doctor$ preclaim doctorupgradeUpdate Preclaim CLI to the latest version
preclaim upgrade$ preclaim upgradeMCP Server
Add preclaim-mcp as an MCP server in any compatible agent. These tools are exposed automatically.
preclaim_lockLock a file before editing it. Call this BEFORE writing to any file to prevent conflicts with other AI sessions. Returns whether the lock was acquired or if another session holds it.
preclaim_unlockRelease a lock on a file, or all locks for this session. Call this after committing changes.
preclaim_checkCheck lock status of one or more files without acquiring locks. Use this to see if files are available before editing.
preclaim_statusList all active locks and sessions for this project. Shows who is working on what.
preclaim_readSignal that you are reading a file. This lets other sessions know you are looking at this file (soft signal, 60s TTL). Call this when reading files to improve coordination.
Claude Code
Run preclaim install-hooks to auto-configure these in .claude/settings.json.
PreToolUseBefore every tool callThe gatekeeper. Intercepts Edit/Write/MultiEdit to acquire file locks before changes, and Read to register soft signals. Discovers config from both the working directory and the file's directory — so locks work even when the session starts from a parent directory. Allows the tool to proceed if the lock is acquired, blocks with a warning if another session holds the lock.
PostToolUseAfter every tool callCommit detector. Watches for git commit commands and automatically releases all session locks when a commit is detected.
SessionStartWhen a Claude Code session startsRegisters the session with Preclaim, starts the heartbeat daemon for automatic lock expiry, and injects a system message with current lock status. Warns authenticated users when no .preclaim.json is found in the current directory.
StopWhen a Claude Code session endsNo-op by design. Cleanup is handled by the activity-aware heartbeat daemon (locks expire when idle), server-side pg_cron cleanup, and daemon self-exit after inactivity.
Config
Created by preclaim init. Modify with preclaim config --set key=value.
backendURL of the Preclaim backend API (default: https://preclaim.dev)projectIdYour Preclaim project ID (set during init)ttlDefault lock TTL in minutes (default: 30)failOpenAllow tool use when Preclaim is unreachable (default: true)ignoreGlob patterns for files to never lock (e.g. *.md, dist/**) (default: [])idleTimeoutMinutesMinutes of inactivity before the heartbeat daemon releases locks