/next-task - Auto-Select Next Priority Task
Pop the next priority task from the V2 project queue and optionally start working on it.
Usage
# Get next priority task (any epic)
/next-task
# Get next task from specific epic
/next-task E001
# Get next task and mark as in_progress
/next-task --start
# Get next task from sprint
/next-task --sprint Sprint-26
# Show task with full context
/next-task --context
# Preview without changing anything
/next-task --dry-run
System Prompt
System Prompt
⚠️ EXECUTION DIRECTIVE: When the user invokes this command, you MUST:
- IMMEDIATELY execute - no questions, no explanations first
- ALWAYS show full output from script/tool execution
- ALWAYS provide summary after execution completes
DO NOT:
- Say "I don't need to take action" - you ALWAYS execute when invoked
- Ask for confirmation unless
requires_confirmation: truein frontmatter - Skip execution even if it seems redundant - run it anyway
The user invoking the command IS the confirmation.
You are the CODITECT task queue manager. When invoked:
- Query the next priority task using
work_items.py:
# Basic - get next priority task
python3 scripts/work_items.py next
# From specific epic
python3 scripts/work_items.py next E001
# With full context
python3 scripts/work_items.py show TASK_ID
- Display task information in this format:
╔══════════════════════════════════════════════════════════════════╗
║ NEXT TASK ║
╚══════════════════════════════════════════════════════════════════╝
Task ID: E001-T042
Title: Implement OAuth token refresh
Status: planned → in_progress (if --start)
Priority: 80
Estimate: 4 hours
Hierarchy:
Project: P001 (CODITECT Platform)
Epic: E001 (Core Platform Autonomy)
Feature: F001.2 (Authentication System)
Sprint: Sprint-26
Source: epics/E001-AUTONOMY/TASKLIST.md:142
──────────────────────────────────────────────────────────────────
Ready to start? Use: /next-task --start
- If --start flag provided, mark task as in_progress:
python3 scripts/work_items.py start TASK_ID
- If --context flag provided, show related tasks:
python3 scripts/work_items.py show TASK_ID
# Also show sibling tasks in same feature
Priority Algorithm
Tasks are selected based on:
- Orphaned Tasks First (ADR-178) - Orphans from
/vacuumget highest priority:dead_claim— claimed by dead session, work may be partially doneconflict_abandoned— cross-session conflict never resolvedstale_in_progress— started >7 days ago, still unchecked- Use
ContextVacuum.get_orphan_priority_list()to get ranked orphans
- Status - Only
plannedtasks are candidates - Priority Score - Higher priority first (1-100)
- Sprint Assignment - Current/earlier sprints first
- Estimate - Smaller tasks break ties (quick wins)
- Epic Order - Earlier epics (E001 < E002) break ties
Orphan Integration (ADR-178)
Before selecting from the work queue, check for orphaned tasks:
import sys
sys.path.insert(0, 'submodules/core/coditect-core')
try:
from scripts.core.context_vacuum import ContextVacuum
vacuum = ContextVacuum()
orphans = vacuum.get_orphan_priority_list()
if orphans:
# Present orphans first with "[ORPHAN]" prefix
# dead_claim > conflict_abandoned > stale_in_progress
pass
except Exception:
orphans = []
Arguments
| Argument | Description |
|---|---|
EPIC_ID | Filter to specific epic (e.g., E001) |
--start | Mark task as in_progress immediately |
--sprint ID | Filter to specific sprint |
--context | Show full task context and related tasks |
--dry-run | Preview only, don't change status |
--json | Output as JSON for automation |
Examples
Basic Next Task
/next-task
Output:
Next Priority Task: E001-T042
Title: Implement OAuth token refresh
Epic: E001 - Core Platform Autonomy
Priority: 80 | Estimate: 4h | Sprint: 26
To start: /next-task --start
Start Working Immediately
/next-task --start
Output:
✓ Started: E001-T042 - Implement OAuth token refresh
Status: planned → in_progress
Started: 2025-12-15T10:30:00Z
Work on this task. When done:
python3 scripts/work_items.py complete E001-T042
Next Task from Specific Epic
/next-task E002
Output:
Next Priority Task from E002:
E002-T001: Initialize React component library
Status: planned | Priority: 85 | Estimate: 8h
Full Context View
/next-task --context
Output:
╔══════════════════════════════════════════════════════════════════╗
║ TASK CONTEXT: E001-T042 ║
╚══════════════════════════════════════════════════════════════════╝
Title: Implement OAuth token refresh
Description: Add automatic token refresh before expiry
Hierarchy:
└── P001: CODITECT Platform
└── E001: Core Platform Autonomy (45% complete)
└── F001.2: Authentication System (30% complete)
└── E001-T042: Implement OAuth token refresh ← YOU ARE HERE
Sibling Tasks in F001.2:
✓ E001-T040: Setup OAuth providers (completed)
✓ E001-T041: Implement login flow (completed)
→ E001-T042: Implement OAuth token refresh (next)
○ E001-T043: Add session management (planned)
○ E001-T044: Write OAuth tests (planned)
Dependencies:
Depends on: E001-T041 ✓ (completed)
Blocks: E001-T043, E001-T044
Source File: epics/E001-AUTONOMY/TASKLIST.md:142
Workflow Integration
Daily Standup Pattern
# Morning: Get next task
/next-task --start
# ... work on task ...
# Complete and get next
python3 scripts/work_items.py complete E001-T042
/next-task --start
Sprint Planning Pattern
# See what's next in current sprint
/next-task --sprint Sprint-26
# Check progress
python3 scripts/work_items.py dashboard
Epic Focus Pattern
# Work through one epic at a time
/next-task E001 --start
# ... complete tasks ...
/next-task E001 --start
Error Handling
No tasks available:
No planned tasks found.
All tasks complete! 🎉
Run: python3 scripts/work_items.py dashboard
Epic not found:
Error: Epic 'E099' not found in database.
Available epics: E001, E002, E003...
Database not initialized:
Error: Database not found at context-storage/sessions.db (ADR-118 Tier 3)
Run: python3 scripts/init-work-item-db.py
Action Policy
<default_behavior> This command queries and displays task. Provides:
- Next priority task
- Task context
- Start option
Only modifies when --start flag used. </default_behavior>
Success Output
When next-task completes:
✅ COMMAND COMPLETE: /next-task
Task: <task-id>
Title: <title>
Priority: <N>
Status: <status>
Action: <displayed|started>
Completion Checklist
Before marking complete:
- Database queried
- Task identified
- Info displayed
- Status updated (if --start)
Failure Indicators
This command has FAILED if:
- ❌ Database not found
- ❌ No tasks available
- ❌ Epic not found
- ❌ Start failed
When NOT to Use
Do NOT use when:
- Already have task assigned
- Need specific task (use show)
- Planning sprint (use dashboard)
Anti-Patterns (Avoid)
| Anti-Pattern | Problem | Solution |
|---|---|---|
| Skip --context | Missing info | Use --context for full view |
| Start without review | Wrong task | Review before --start |
| Ignore priority | Wrong order | Follow priority algorithm |
Principles
This command embodies:
- #3 Complete Execution - Full task retrieval
- #6 Clear, Understandable - Clear task display
- #9 Based on Facts - Priority-based selection
Full Standard: CODITECT-STANDARD-AUTOMATION.md
Script: scripts/work_items.py
Database: context-storage/sessions.db (ADR-118 Tier 3)
Standard: ADR-006 Work Item Hierarchy
Version: 1.0.0