Skip to content
verify-task-ownership logo

Verify Task Ownership Skill

verify-task-ownership

Verify session ownership before working on existing tasks (multi-instance coordination)

SKILL.md

Full skill instructions

Verify Task Ownership Skill

Purpose: Check if an existing task is owned by the current session before working on it. Prevents multiple Claude instances from conflicting on the same task.

Why This Matters: When multiple Claude Code instances run concurrently, each may find existing tasks in various states. Without ownership verification, one instance may take over another's work-in-progress, causing conflicts and lost work.

When to Use This Skill

Use verify-task-ownership When:

  • Task directory already exists at /​workspace/​tasks/​{task-name}/
  • Before resuming work on any existing task
  • When finding a task in AWAITING_USER_APPROVAL state
  • Starting a session and checking for continuable work

Do NOT Use When:

  • Creating a new task (task directory doesn't exist)
  • Task confirmed as yours from previous check in same session
  • Working on task you just initialized with task-init

Ownership Verification Process

Step 1: Check if Task Directory Exists

TASK_NAME="{task-name}"
TASK_DIR="/​workspace/​tasks/​$TASK_NAME"

if [ ! -d "$TASK_DIR" ]; then
  echo "Task directory doesn't exist - safe to create new task"
  exit 0  # PROCEED with task-init
fi

Step 2: Check task.json for Session Ownership

# Get session_id from task.json
LOCK_SESSION=$(jq -r '.session_id // "missing"' "$TASK_DIR/​task.json" 2>/​dev/​null)

# Get current session ID (from SessionStart hook)
CURRENT_SESSION_ID="${CLAUDE_SESSION_ID:-unknown}"

Step 3: Apply Decision Matrix

if [ "$LOCK_SESSION" = "missing" ] || [ -z "$LOCK_SESSION" ]; then
  echo "WARNING: Task exists but has no session_id"
  echo "Another instance may be working on this - ASK USER before proceeding"
  # DO NOT PROCEED - another instance may own this task

elif [ "$LOCK_SESSION" != "$CURRENT_SESSION_ID" ]; then
  echo "ERROR: Task owned by different session: $LOCK_SESSION"
  echo "SELECT A DIFFERENT TASK - this one is taken"
  # MUST NOT work on this task

else
  echo "SUCCESS: Task owned by current session - can resume"
  # SAFE to continue working on this task
fi

Decision Matrix

task.json exists?Has session_id?Matches current?Action
NON/​AN/​APROCEED - Create new task.json with YOUR session_id
YESNON/​AASK USER - Another instance may be working on this
YESYESNOSELECT DIFFERENT TASK - Another instance owns this
YESYESYESRESUME - Continue your previous work

Complete Verification Script

#!/​bin/​bash
set -euo pipefail

TASK_NAME="${1:?Task name required}"
CURRENT_SESSION_ID="${2:-${CLAUDE_SESSION_ID:-unknown}}"
TASK_DIR="/​workspace/​tasks/​$TASK_NAME"

echo "=== Verifying Task Ownership ==="
echo "Task: $TASK_NAME"
echo "Current Session: $CURRENT_SESSION_ID"

# Step 1: Check if task exists
if [ ! -d "$TASK_DIR" ]; then
  echo ""
  echo "Result: PROCEED"
  echo "Task directory doesn't exist. Safe to create new task with task-init."
  exit 0
fi

# Step 2: Check task.json
if [ ! -f "$TASK_DIR/​task.json" ]; then
  echo ""
  echo "Result: ASK_USER"
  echo "Task directory exists but no task.json found."
  echo "Another instance may have partially created this task."
  exit 1
fi

# Step 3: Get ownership info
LOCK_SESSION=$(jq -r '.session_id // "missing"' "$TASK_DIR/​task.json" 2>/​dev/​null)
TASK_STATE=$(jq -r '.state // "unknown"' "$TASK_DIR/​task.json" 2>/​dev/​null)

echo "Task State: $TASK_STATE"
echo "Task Owner: $LOCK_SESSION"

# Step 4: Apply decision matrix
if [ "$LOCK_SESSION" = "missing" ] || [ -z "$LOCK_SESSION" ]; then
  echo ""
  echo "Result: ASK_USER"
  echo "Task exists but has no session_id - cannot determine owner."
  echo "Ask user: 'Task $TASK_NAME exists but has no owner recorded. Should I take it over?'"
  exit 1

elif [ "$LOCK_SESSION" != "$CURRENT_SESSION_ID" ]; then
  echo ""
  echo "Result: SELECT_DIFFERENT_TASK"
  echo "Task is owned by a different Claude instance."
  echo "Owner session: $LOCK_SESSION"
  echo "Your session: $CURRENT_SESSION_ID"
  echo "Choose a different task to work on."
  exit 2

else
  echo ""
  echo "Result: RESUME"
  echo "Task is owned by current session."
  echo "Safe to resume work on this task."
  exit 0
fi

Common Mistakes

Mistake: Taking Over Another Instance's Task

❌ WRONG:
"I see task implement-feature is in AWAITING_USER_APPROVAL state.
Let me present it for approval..."
[But this task was created by a different Claude instance!]
✅ CORRECT:
"I see task implement-feature exists. Let me verify ownership..."
[Runs verification]
"This task is owned by session abc-123, but my session is xyz-789.
I'll select a different task to work on."

Mistake: Not Recording Session ID

When creating tasks, ALWAYS include session_id:

{
  "task_name": "implement-feature",
  "session_id": "your-session-id-here",  // ← REQUIRED
  "state": "INIT",
  "created": "2025-12-04T15:00:00Z"
}

Integration with task-init

The task-init skill accepts session_id as 3rd parameter:

/​workspace/​main/​.claude/​scripts/​task-init.sh "$TASK_NAME" "$DESCRIPTION" "$SESSION_ID"

This ensures new tasks are properly tagged with ownership information.

Workflow Integration

[Session starts]
        ↓
[Receive task assignment]
        ↓
[Check if task directory exists]
        ↓
    ┌───┴───────────────────┐
    │ NO                    │ YES
    ↓                       ↓
[Use task-init          [Invoke verify-task-ownership skill]
 with session_id]               ↓
    │               ┌───────────┴───────────┐
    │               │                       │
    │          RESUME (yours)          DIFFERENT OWNER
    │               ↓                       ↓
    │        [Continue work]         [Select different task]
    ↓               ↓                       ↓
[Work on task]  [Work on task]      [Back to task selection]

Related Skills

  • task-init: Creates new tasks with session_id ownership tracking
  • state-transition: Manages task state changes (respects ownership)

Environment Variables

  • CLAUDE_SESSION_ID: Current session identifier (set by SessionStart hook)

Troubleshooting

"No session_id in task.json"

Task was created before ownership tracking was added. Options:

  1. Ask user if you should take ownership
  2. If user confirms, update task.json with your session_id
  3. If unsure, select a different task

"Session ID is 'unknown'"

Your session ID wasn't properly set. Check:

  1. SessionStart hook ran successfully
  2. CLAUDE_SESSION_ID environment variable is set
  3. Session ID was passed to verify script

Multiple Instances Want Same Task

This is expected behavior! The ownership system ensures only one instance works on each task. Other instances should select different tasks from todo.md or wait for the current owner to complete.

More Productivity & Planning skills

brainstorming logo
Productivity & Planning

brainstorming

Structured design dialogue that validates ideas before implementation begins.

295.4K 385.7K
View
ui-ux-pro-max logo
Productivity & Planning

ui-ux-pro-max

Comprehensive design intelligence for web and mobile UI/UX across 10 technology stacks.

133.1K 383.9K
View
writing-plans logo
Productivity & Planning

writing-plans

Comprehensive implementation plans for multi-step tasks, breaking down specs into bite-sized, testable steps.

295.4K 268K
View
using-superpowers logo
Productivity & Planning

using-superpowers

Introduction to the obra skills system with mandatory skill invocation rules and best practices.

295.4K 259.8K
View
executing-plans logo
Productivity & Planning

executing-plans

Execute a written implementation plan with critical review and task checkpoints.

295.4K 229.1K
View
dispatching-parallel-agents logo
Productivity & Planning

dispatching-parallel-agents

Delegate independent tasks to specialized agents working concurrently with isolated context.

295.4K 206.3K
View
using-git-worktrees logo
Productivity & Planning

using-git-worktrees

Isolated git worktrees with smart directory selection and safety verification.

295.4K 205.2K
View
webapp-testing logo
Productivity & Planning

webapp-testing

Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.

179.7K 170.6K
View
content-strategy logo
Productivity & Planning

content-strategy

Plan searchable and shareable content that drives traffic, builds authority, and generates leads.

53.3K 150.9K
View
repo-intake-and-plan logo
Productivity & Planning

repo-intake-and-plan

README-first repository scanner that extracts commands and classifies reproduction candidates without executing them.

497 139.6K
View
marketing-ideas logo
Productivity & Planning

marketing-ideas

Brainstorm and prioritize marketing strategies tailored to your SaaS stage, budget, and goals.

53.3K 137.2K
View
site-architecture logo
Productivity & Planning

site-architecture

Plan and optimize your website's page hierarchy, navigation, URL structure, and internal linking.

53.3K 112.8K
View

Productivity AI tools

Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View
SaveDay logo
Productivity

SaveDay

Capture, organize, and utilize your knowledge effortlessly.

Free
View
A
Productivity

Any Summary

Instant Summaries of Audio & Video Interviews with AnySummary

Freemium
View
M
Productivity

Map This

Transform PDFs into engaging mind maps.

Freemium
View
ChatPDF logo
Productivity

ChatPDF

Chat with any PDF instantly

Free
View
I
Productivity

intellisay

Create an optimal daily plan using your voice

Paid
View
A
Productivity

Aurora AI

A productivity platform to centralize organizational knowledge and workflows with contextual AI assistance.

Paid
View
AskYourPDF logo
Productivity

AskYourPDF

AskYourPDF Pricing Plans: Tailored to Your Needs

Free
View