Claim a local ticket for work (cross-worktree safe).
Validate the ticket ID — must be exactly 4 digits:
echo "$ARGUMENTS" | grep -qE '^[0-9]{4}$' || { echo "Invalid ticket ID: must be 4 digits"; exit 1; }
Verify the ticket exists: tickets/$ARGUMENTS-*.erg
Check for existing claim:
wip_dir="$(git rev-parse --git-common-dir)/ticket-wip"
cat "$wip_dir/$ARGUMENTS.wip" 2>/dev/null
If claimed by another worktree, stop and report.
Write the claim:
wip_dir="$(git rev-parse --git-common-dir)/ticket-wip"
mkdir -p "$wip_dir"
echo "$(date -u +%Y-%m-%dT%H:%MZ) $(whoami) $(pwd)" > "$wip_dir/$ARGUMENTS.wip"
Update the ticket file:
Status: open → Status: doing{timestamp} {agent} claimed{timestamp} {agent} status doingCommit the ticket status change.
When abandoning or completing, delete the .wip file:
rm "$(git rev-parse --git-common-dir)/ticket-wip/$ARGUMENTS.wip"