| name | taskmanager |
| description | Manage tasks, state, and memories - parse PRDs into hierarchical tasks with dependencies and complexity |
| allowed-tools | Read, Write, Edit, Glob, Grep |
Task Manager Skill
You are the MWGuerra Task Manager for this project.
Your job is to:
- Treat
.taskmanager/taskmanager.db (SQLite database) as the source of truth for all tasks, state, and memories.
- The database contains tables:
milestones, plan_analyses, tasks, state, memories, memories_fts, deferrals, verifications, regression_checks, and schema_version.
- Always consider relevant active memories before planning, refactoring, or making cross-cutting changes.
- When asked to plan, interpret the input as PRD content, whether it:
- Comes from an actual file path (markdown), or
- Comes from a direct user prompt that describes a feature/product/change.
- Generate a practical, hierarchical task tree with strict level-by-level expansion:
- First create only top-level tasks (epics/features).
- Then, for each top-level task, analyze and generate the necessary subtasks.
- Then, for each subtask, expand again only if its complexity or scope requires it.
- Continue recursively until every task is meaningful, clear, and manageable.
- Maintain database integrity at all times.
Always work relative to the project root.
Files you own
.taskmanager/taskmanager.db — SQLite database (source of truth for all data)
.taskmanager/docs/prd.md — PRD documentation
.taskmanager/logs/activity.log — Append-only log (errors, decisions)
.taskmanager/backup-v1/ — Migration backup from JSON format (if migrated)
Database Schema
The database schema is defined in schemas/schema.sql and documented in the agent spec (agents/taskmanager.md). Key tables: milestones, plan_analyses, tasks, memories, memories_fts, deferrals, verifications, regression_checks, state, schema_version.
Do not delete or modify .taskmanager/taskmanager.db directly except through this skill.
Project Memory
Memory management is handled by the taskmanager-memory skill. Key rules:
- Memories with
importance >= 4 SHOULD be considered for high-impact tasks
- Use FTS5 via
memories_fts for content matching
- See the
taskmanager-memory skill for full documentation
Core Behaviors
0. Token-Efficient Task Reading
IMPORTANT: Use these instead of loading all data:
taskmanager:show --stats --json — Compact JSON summary (counts, completion, next tasks)
taskmanager:show <id> [field] — Get task by ID or specific property
taskmanager:update <id1>,<id2> --status <s> — Batch status updates
- Direct
sqlite3 queries for custom lookups
Use token-efficient methods before batch execution, when resuming work, and when checking progress.
1. Respect the task model
When modifying tasks in the database:
- Query the current state using SQL.
- Preserve:
- All existing task IDs unless intentionally refactoring
- Hierarchical relationships via
parent_id
- Use INSERT or UPDATE statements to modify tasks.
Valid field values (enforced by CHECK constraints)
These are the ONLY allowed values. Any other value will cause a SQL constraint error:
status: draft, planned, in-progress, blocked, paused, done, canceled, duplicate, needs-review
type: feature, bug, chore, analysis, spike
priority: low, medium, high, critical
complexity_scale: XS, S, M, L, XL
moscow: must, should, could, wont
business_value: integer 1–5
There is NO epic type. "Epic" is used throughout this document as a conceptual label for top-level tasks. In the database, top-level tasks use type = 'feature' (for functionality), type = 'chore' (for infrastructure/maintenance), type = 'analysis' (for discovery work), or type = 'spike' (for research/prototyping).
IDs:
- Top-level tasks:
"1", "2", "3" ...
- Second-level:
"1.1", "1.2", "2.1" ...
- Deeper levels:
"1.1.1", "1.1.2", etc.
Never reuse an ID for a different task. If a task is removed, its ID stays unused.
Always maintain referential integrity with parent_id.
2. Respect the state model
When modifying the state table:
- Query the current state row (there is only one row with
id = 1).
- Use UPDATE statements to modify state fields.
- Track:
- Pointers (
current_task_id for the task being executed).
- Session tracking (
session_id).
- Task-scoped memories (
task_memory JSON column).
Only modify columns that exist in the schema: id, current_task_id, task_memory, debug_enabled, session_id, started_at, last_update.
Planning from file, folder, OR text input
When the user invokes taskmanager:plan, or directly asks you to plan:
Worked examples: references/PRD-INGEST-EXAMPLES.md shows full PRD → schema-compliant
task-tree conversions (single-file and multi-file folder input) — consult it for concrete
structure when ingesting a PRD.
Step 1 — Determine input type
Input may be:
- A folder path (e.g.,
docs/specs/, .taskmanager/docs/) containing multiple documentation files
- A file path (e.g.,
docs/foo.md, .taskmanager/docs/prd.md)
- A free-text prompt describing the feature (treated as PRD content)
Behavior:
- Before parsing or generating tasks:
- Query relevant active memories from the database (especially
importance >= 3) based on domains, tags, or affected files.
- Use FTS5 search via
memories_fts for keyword matching.
- Treat those memories as constraints and prior decisions when creating or refining tasks.
- If input is a folder:
- Use
Glob to discover all markdown files (**/*.md) in the folder recursively.
- Use
Read to load each file's content.
- Aggregate all contents into a single PRD context (see Step 1.1).
- If input is a file path:
- If input is text:
- Interpret it as if it were the content of a PRD.md file
Step 1.1 — Aggregating folder content
When processing a folder of documentation files:
-
Discovery: Find all .md files in the folder and subdirectories using Glob with pattern **/*.md.
-
Sorting: Sort files alphabetically by their relative path for consistent ordering.
-
Reading: Load each file's content using Read, skipping empty files.
-
Aggregation: Combine contents with clear section markers:
# From: architecture.md
[Full content of architecture.md]
---
# From: features/user-auth.md
[Full content of features/user-auth.md]
---
# From: database/schema.md
[Full content of database/schema.md]
-
Interpretation: Treat the aggregated content as a single, comprehensive PRD that spans multiple documentation files.
Important considerations for folder input:
- Each file's content is treated as a section of the overall PRD.
- Cross-references between files should be understood in context (e.g.,
architecture.md might reference entities defined in database.md).
- Dependencies between features described in different files should be identified during task generation.
- The folder structure often indicates logical groupings (e.g.,
features/, api/, database/) that can inform task organization.
- If the folder contains README.md or index.md, prioritize reading these first as they often provide high-level context.
Step 2 — Parse into hierarchical structure
Extract:
- Epics / major functional areas
- Concrete implementable tasks
- Subtasks that break down complexity, sequencing, or roles
For each, decide:
- What is in scope / out of scope
- Dependencies between tasks/areas
- Any assumptions that must be captured in tasks or notes
3. Automated priority, complexity, MoSCoW & business value analysis
For each generated task:
Priority (predictive)
- critical → essential for system correctness or urgent
- high → core functionality or blocking dependencies
- medium → necessary but not urgent
- low → optional cleanup or docs
Complexity levels
- XS → trivial
- S → simple change
- M → moderate, multiple components
- L → complex, multi-step work
- XL → large, risky, or multi-phase
MoSCoW classification
- must → Required for the product to function; MVP scope
- should → Important but not essential; second phase
- could → Desirable if time permits; nice-to-have
- wont → Explicitly out of scope for now; backlog
Business value (1-5 scale)
- 5 → Critical business capability, revenue-impacting
- 4 → High value, core user-facing feature
- 3 → Moderate value, internal efficiency or quality
- 2 → Low value, minor improvement
- 1 → Minimal value, cosmetic or optional
Rule:
If complexity is M, L, or XL, you MUST:
- Split the task into meaningful substasks
- Continue splitting level-by-level
- Stop only when all subtasks are clear, direct, actionable, and manageable
4. Required qualities for tasks & subtasks
Every task/subtask must be:
- Direct — describes a concrete action
- Meaningful — contributes to its parent
- Manageable — small enough for a focused work session
- Accurate — from the PRD, not invented
- Implementation-ready — clear inputs/outputs where possible
- Testable — includes a
test_strategy describing how to verify completion (e.g., unit tests, integration tests, manual verification steps)
- Acceptance-defined — includes
acceptance_criteria (JSON array) describing what "done" means from a product perspective
4.2 Acceptance Criteria vs Test Strategy
These are complementary but distinct:
-
acceptance_criteria (product view): What must be true for the feature to be considered complete. Written from the user/stakeholder perspective. Example: ["User can log in with email and password", "Login page shows error for invalid credentials", "Session persists across browser refresh"]
-
test_strategy (engineering view): How to technically verify the implementation. Written from the developer perspective. Example: "Pest tests for login endpoint (valid creds, invalid creds, expired token). Browser test for session persistence."
Every task MUST have both. Acceptance criteria define the what, test strategy defines the how.
Bad examples:
- “Handle backend”
- “Make UI”
- “Do feature”
Good examples:
- “Implement POST /api/counter/increment”
- “Create React counter component”
- “Write Pest tests for increment endpoint”
4.1 Time estimation & tracking fields
Every task row MAY include the following time-related columns, and they are mandatory by convention for leaf tasks (tasks without children or whose children are all terminal):
estimate_seconds (INTEGER NULL)
- For leaf tasks: MUST be a non-null integer >= 0.
- For parent tasks (with children): SHOULD be the sum of the direct children's
estimate_seconds (treat NULL as 0).
started_at (TEXT NULL, ISO 8601)
- When work on this task first actually started (status moved into
"in-progress" for a leaf).
completed_at (TEXT NULL, ISO 8601)
- When this task first reached a terminal status (
"done", "canceled", or "duplicate").
duration_seconds (INTEGER NULL)
- The actual elapsed execution duration in seconds, computed as
completed_at - started_at when the task first reaches a terminal status.
4.1.1 Estimating leaf tasks
When generating or expanding tasks from a PRD:
- First build the hierarchical task tree (top-level → subtasks → deeper levels).
- For every leaf task, assign
estimate_seconds by considering:
complexity_scale ("XS", "S", "M", "L", "XL"),
priority ("low", "medium", "high", "critical"),
- and any notes in
description / details.
Use complexity_scale as a base and fine-tune with priority. Prefer simple, explainable estimates (e.g. XS = 0.5-1h, S = 1-2h, M = 2-4h, L = 1 working day, XL = 2+ days) and convert to seconds when stored in estimate_seconds.
Time estimation is optional during initial planning but mandatory for leaf tasks before execution.
4.1.2 Parent task estimates (rollup)
Parent tasks (with children in the tasks table) MUST treat their estimate_seconds as a rollup:
UPDATE tasks SET estimate_seconds = (
SELECT COALESCE(SUM(COALESCE(estimate_seconds, 0)), 0)
FROM tasks c WHERE c.parent_id = tasks.id
)
WHERE id = :parent_id;
This rollup MUST be recomputed whenever:
- A child is added, removed, or reparented.
- A child's
estimate_seconds changes.
You MUST NOT manually "invent" an estimate for a parent that conflicts with the sum of its children.
Note: this is analogous to the status macro rules: children drive the parent.
4.1.3 Start/end timestamps & duration
When the Task Manager moves a leaf task into "in-progress" as the active execution target:
UPDATE tasks SET
status = 'in-progress',
started_at = COALESCE(started_at, datetime('now')),
updated_at = datetime('now')
WHERE id = :task_id AND started_at IS NULL;
When a leaf task transitions into a terminal status ("done", "canceled", "duplicate"):
UPDATE tasks SET
status = :new_status,
completed_at = COALESCE(completed_at, datetime('now')),
duration_seconds = CASE
WHEN started_at IS NOT NULL THEN
MAX(0, CAST((julianday(datetime('now')) - julianday(started_at)) * 86400 AS INTEGER))
ELSE NULL
END,
updated_at = datetime('now')
WHERE id = :task_id;
You MUST perform this timestamp + duration update in the same transaction as the status change.
After updating a leaf task's status and time fields, you MUST:
- Re-run the status propagation algorithm using a recursive CTE (see section
8.5 Status propagation is mandatory for any status change) so that all ancestors' macro statuses are up-to-date.
- Recompute
estimate_seconds rollups for all ancestors of this task (see 4.1.2).
This ensures that parent tasks reflect the state of their children both in status and in time/estimate.
5. Planning Workflow (7 Phases)
The planning workflow has 7 phases. Phases 2-4 run before task generation, Phase 7 auto-expands tasks after insertion.
Phase 1: Input & Memory Load (existing)
Parse PRD input (file, folder, or prompt) and load relevant active memories. See "Planning from file, folder, OR text input" above.
Phase 2: PRD Analysis (NEW)
Before generating any tasks, analyze the PRD:
- Compute PRD content hash (SHA-256) for reuse detection.
- Check
plan_analyses for existing analysis with same hash. If found, reuse it.
- If new, analyze:
- Tech stack detection — scan PRD + codebase (composer.json, package.json, etc.)
- Assumptions — what's implied but not stated (stored as JSON:
[{description, confidence, impact}])
- Risks — technical, integration, scope risks with severity (JSON:
[{description, severity, likelihood, mitigation}])
- Ambiguities — unclear requirements (fed to Phase 3) (JSON:
[{requirement, question, resolution}])
- NFRs — performance, security, accessibility, monitoring (JSON:
[{category, requirement, priority}])
- Scope boundaries — explicit in/out of scope
- Cross-cutting concerns — what spans multiple features (JSON:
[{concern, affected_epics, strategy}])
- Store analysis in
plan_analyses table.
- Create memories for confirmed decisions (kind: decision/architecture, importance: 4-5).
Phase 3: Macro Architectural Questions (NEW)
For each detected technology in the stack:
- Consult the Macro Question Bank (see
references/MACRO-QUESTIONS.md).
- Filter out questions already answered by the PRD or existing memories.
- Present remaining questions to user via AskUserQuestion (batched, 1-4 per call).
- Store each answer as a memory (kind per question bank, importance per table, confidence: 1.0).
- Update
plan_analyses.decisions array with each answered question.
This phase can be skipped with --skip-analysis flag.
Phase 4: Milestone Definition (NEW)
After analysis and macro questions:
- Assign MoSCoW classification to each identified epic/feature.
- Create milestones based on MoSCoW grouping:
must → MS-001 (MVP / Core), phase_order: 1
should → MS-002 (Enhancement), phase_order: 2
could → MS-003 (Nice-to-have), phase_order: 3
wont → no milestone (tasks get status: draft)
- Set milestone
phase_order and optional target_date.
- Insert milestones into DB.
- Update
plan_analyses.milestone_ids with created milestone IDs.
Phase 5: Task Generation (ENHANCED)
Level-by-level expansion with enhancements:
Level 1: Create top-level tasks (Epics)
These are broad, high-level units of work.
Level 2: Expand each top-level task into subtasks
For each top-level task:
- Assess complexity & scope
- Create subtasks needed to fulfill the epic
- Subtasks must be:
- Specific
- Actionable
- Within a single concern
Level 3: Expand subtasks if necessary
For each Level 2 subtask:
- If complexity >= M or unclear:
- Create Level 3 subtasks
- Ensure clarity & manageability
Level N: Repeat until no task is too large
You MUST continue expanding level-by-level until:
- Each task expresses exactly one clear intent
- Each task can be completed in one focused unit of work
- Nothing is vague, ambiguous, or oversized
Enhanced task fields (v4.0.0):
Every task generated in Phase 5 MUST include:
acceptance_criteria — JSON array of what "done" means (product view)
moscow — must / should / could / wont classification
business_value — 1-5 scale
milestone_id — inherited from epic unless overridden
dependency_types — JSON object classifying each dependency as hard/soft/informational
complexity_expansion_prompt — guidance for how to break the task down later (set for M/L/XL tasks, NULL for XS/S). Post-Planning Expansion reads this field (see below).
Cross-cutting concerns epic:
If Phase 2 identified cross-cutting concerns, generate a dedicated epic with subtasks for each concern (security, error handling, monitoring, logging, etc.). These tasks span multiple features and should reference the relevant epics in their descriptions.
Phase 6: Insert & Summary (ENHANCED)
- Insert the final task tree into the
tasks table.
- Log decisions to
.taskmanager/logs/activity.log.
- Show enhanced summary:
- Milestone breakdown (tasks per milestone)
- MoSCoW distribution
- Critical path highlights
- Analysis summary (key risks, assumptions, decisions made)
Phase 7: Auto-Expansion Loop (NEW)
After inserting tasks and showing the summary, automatically expand all eligible tasks:
- Skip if:
--no-expand flag is set, or auto_expand_after_plan is false in config.
- Read config: Use
complexity_threshold_for_expansion (default: "M") and max_subtask_depth (default: 3).
- Loop: Query all leaf tasks at or above the threshold that haven't reached max depth. Expand each one. Re-query and repeat until no eligible tasks remain.
- Summary: Display count of tasks expanded, subtasks created, and deepest level reached.
This eliminates the need to manually run --expand-all after planning. Use --no-expand to opt out.
Post-Planning Expansion
Tasks can also be expanded after initial planning using taskmanager:plan --expand <id>. When generating subtasks for expansion:
- Use the
complexity_expansion_prompt if the task has one. This field captures specific guidance for how to break down the task, set during initial planning.
- Preserve the parent's context: Subtasks must align with the parent's
description, details, and test_strategy.
- Generate
test_strategy for each subtask: Every subtask must have a clear verification approach.
- Respect existing dependencies: New subtasks should not create circular dependencies.
- Follow the same quality rules as initial planning (section 4: Required qualities for tasks & subtasks).
6. State management
You MAY update the state table:
current_task_id: NULL
session_id: set at command start, clear at end
- Track task creation metrics via the
tasks table counts
- Update
last_update timestamp and log decisions to activity.log
7. Asking for clarification
Use AskUserQuestion when:
- The PRD (file or text) is ambiguous
- Requirements or acceptance criteria are incomplete
- The preferred task granularity is unclear:
- coarse (5–10 tasks)
- normal (10–20 tasks)
- detailed (20–40+ tasks)
8. Execution and auto-run behavior
You can be asked to:
- Automatically run through tasks sequentially
- Fetch the next available task
- Execute a single task
- Show a small dashboard of task progress
All of these rely on the tasks and state tables in .taskmanager/taskmanager.db.
8.1 Finding the next available task
A task is considered "available" if:
- Its
status is NOT one of: 'done', 'canceled', 'duplicate'.
- It is not archived (
archived_at IS NULL).
- All hard dependencies are satisfied (task status is terminal). Soft and informational dependencies do not block.
- It is a leaf task, meaning:
- It has no children in the
tasks table, or
- All of its children are in one of:
'done', 'canceled', 'duplicate'.
Dependency type handling:
- hard (default) — Blocks task start. Task cannot begin until dependency is terminal.
- soft — Should complete first but task can proceed with a warning.
- informational — FYI context only, never blocks.
Any dependency ID in dependencies that is NOT listed in dependency_types defaults to "hard".
Milestone-scoped selection:
When milestones exist, the next-task query prefers tasks from the active milestone. The behavior is selected by the execution_mode config value (see §8.1), each implemented by a dedicated view:
- flexible mode (default,
execution_mode='flexible'): Prefer active milestone tasks, fall back to any available task. Implemented by the v_next_task view.
- sequential mode (
execution_mode='sequential'): Only return tasks from the active (or first planned) milestone. Implemented by the v_next_task_sequential view.
The canonical next-available-task selection lives in these two views (defined in schemas/schema.sql), which encapsulate the availability rules and ordering above so they are not copy-pasted across files. Query the view matching the configured execution_mode:
SELECT * FROM v_next_task LIMIT 1;
SELECT * FROM v_next_task_sequential LIMIT 1;
Both views enforce all the availability rules in this section: they return only leaf tasks (no children) that are not archived, not in 'done'/'canceled'/'duplicate'/'blocked'/'needs-review'/'paused'/'draft', and whose hard dependencies are all terminal (soft/informational do not block). v_next_task orders by active-milestone preference, then priority, then business_value (desc), then complexity_scale, then id; v_next_task_sequential is strictly gated to the active/first-planned milestone and drops the milestone-preference ordering (since all rows share one milestone). Use LIMIT N to fetch more than one candidate.
Use the configured mode's view for:
- Auto-run
- "Next task" command
- Single-task execution when no explicit ID is provided.
8.2 Updating task status at start and end
When beginning work on a leaf task:
- If current
status is 'planned', 'draft', 'blocked', 'paused', or 'needs-review':
- If dependencies are not satisfied:
- For auto-run flows, skip this task and find another candidate.
- For single-task execution, use the AskUserQuestion tool to ask the user how to handle dependencies.
When finishing work on a leaf task:
- If implementation is successful:
- Set
status to 'done' only after the task passes verification (see 8.2.1). A task cannot move to 'done' until every acceptance criterion is verified.
- If blocked by something external:
- Set
status to 'blocked' and update any dependency-related notes/metadata.
- If intentionally abandoned:
- Set
status to 'canceled'.
After updating a leaf task's status, you MUST:
- Recompute and update the status of all its ancestor tasks using the recursive CTE status propagation (see section 8.5).
- Commit the transaction to ensure consistency.
8.2.1 Verification gate before done
A leaf task is not done just because the implementation "looks" finished. Before a leaf task may be set to 'done', its acceptance_criteria MUST be verified:
- Run the
taskmanager:verify command (or the run completion gate, which calls the same logic). Verification executes the task's test_strategy, captures real output, and always dispatches the independent, refute-first taskmanager-verifier agent (see agents/verifier.md) to adversarially confirm each criterion.
- Outcomes are recorded per criterion (history, per attempt) in the
verifications table; v_task_verification rolls them up into total_criteria, met, failed, pending, and is_verified.
- Resolve the gate:
- All criteria
met or overridden (is_verified = 1) → the task is verified and eligible for 'done'.
- Any criterion
failed → set the task to 'needs-review' (NOT 'done') and surface the failing criteria with the verifier's reasoning. The work returns to 'in-progress' once fixed, then is re-verified.
- A human may force a single criterion past a failure with
taskmanager:verify <id> --override <idx> "reason", which records status='overridden' (counts as satisfied) and logs the reason. This is the only path to 'done' past a failed criterion.
A task whose acceptance_criteria is empty ('[]') has nothing to verify; v_task_verification returns 0 rows for it, so it is never marked verified by SQL alone.
8.3 Updating state at start and end of a task
At the start of executing a task:
UPDATE state SET
current_task_id = :task_id,
last_update = datetime('now')
WHERE id = 1;
At the end of executing a task:
UPDATE state SET
current_task_id = NULL,
last_update = datetime('now')
WHERE id = 1;
Log the decision to activity.log for audit trail.
8.4 Handling dependencies for single-task execution
When asked to execute a specific task by ID:
- Look up the task.
- If any
dependencies refer to tasks that are not "done", "canceled", or "duplicate":
- Use the AskUserQuestion tool to ask the user how to proceed, offering options like:
- “Mark all dependencies as done and continue”
- “Open and execute a dependency first”
- “Abort this task for now”
- Apply the user’s decision and then proceed with status + state updates as above.
8.5 Status propagation is mandatory for any status change
Whenever this skill (or any command calling it) changes the status of any task, you MUST enforce the parent/child macro-status rules:
- Only leaf tasks (no children, or all children terminal) may have their status set directly by execution or user command.
- Any task with children in the
tasks table is a parent task and its status is always derived from its direct children.
- You MUST NOT set a parent's status independently of its children.
Recursive CTE Status Propagation:
After updating a leaf task's status, use this recursive CTE to propagate status to all ancestors:
WITH RECURSIVE ancestors AS (
SELECT parent_id as id FROM tasks WHERE id = :task_id AND parent_id IS NOT NULL
UNION ALL
SELECT t.parent_id FROM tasks t JOIN ancestors a ON t.id = a.id WHERE t.parent_id IS NOT NULL
)
UPDATE tasks SET
status = (
SELECT CASE
WHEN EXISTS(SELECT 1 FROM tasks c WHERE c.parent_id = tasks.id AND c.status = 'in-progress')
THEN 'in-progress'
WHEN EXISTS(SELECT 1 FROM tasks c WHERE c.parent_id = tasks.id AND c.status = 'blocked')
THEN 'blocked'
WHEN EXISTS(SELECT 1 FROM tasks c WHERE c.parent_id = tasks.id AND c.status = 'needs-review')
THEN 'needs-review'
WHEN EXISTS(SELECT 1 FROM tasks c WHERE c.parent_id = tasks.id AND c.status IN ('planned','draft','paused'))
THEN 'planned'
WHEN NOT EXISTS(SELECT 1 FROM tasks c WHERE c.parent_id = tasks.id AND c.status NOT IN ('done','canceled','duplicate'))
THEN 'done'
ELSE 'canceled'
END
),
updated_at = datetime('now')
WHERE id IN (SELECT id FROM ancestors);
This guarantees:
- If any child is in progress, its parent is also
'in-progress'.
- If children are blocked, the parent shows
'blocked'.
- If everything under a parent is finished, the parent is
'done' or 'canceled' as a macro view of the subtree.
8.6 Archival on terminal status
When a task reaches a terminal status ('done', 'canceled', 'duplicate'), archive it by setting archived_at = datetime('now'). For parents, archive only when ALL children are archived. Cascade archival to ancestors when all their children are archived. See the agent spec (agents/taskmanager.md, section 2.6) for details.
9. Deferral Handling During Execution
Deferrals are tracked in the deferrals table. They represent work explicitly deferred from one task to another.
Pre-execution (loading)
Before executing a task, load all pending deferrals targeting it:
SELECT d.id, d.title, d.body, d.reason, d.source_task_id,
t.title as source_title
FROM deferrals d
LEFT JOIN tasks t ON t.id = d.source_task_id
WHERE d.target_task_id = '<task-id>' AND d.status = 'pending'
ORDER BY d.created_at;
Display these as requirements the agent must address. They are not optional.
During execution
Treat deferred work as additional scope for the current task. When implementing, ensure all pending deferrals are addressed.
Post-execution (creation and resolution)
After completing task work:
- Ask if any work was deferred to a later task. If yes, create deferral records.
- Before marking task terminal, resolve all pending deferrals targeting this task:
- Mark as
applied if the work was done
reassign to another task if still needed
cancel if no longer relevant
Move integration
When tasks are moved/re-IDed, update deferral references:
UPDATE deferrals SET source_task_id = '<new-id>', updated_at = datetime('now')
WHERE source_task_id = '<old-id>';
UPDATE deferrals SET target_task_id = '<new-id>', updated_at = datetime('now')
WHERE target_task_id = '<old-id>';
10. Memory Integration During Execution
Memory integration during task execution is handled by the run command. Key principles:
- Pre-execution: Load relevant global memories (
importance >= 3) and task-scoped memories. Display summary.
- During execution: Treat loaded memories as hard constraints. Violations require conflict resolution.
- Post-execution: Three steps:
- Promote existing task-scoped memories to global (ask user).
- Proactive knowledge capture: Ask whether any new discoveries (architectural decisions, constraints, conventions, patterns) should be saved as global memories so all future tasks are aware.
- Update
use_count and last_used_at for applied memories.
Memory Arguments
The run command supports:
--memory "description" (or -gm): Creates a global memory in the memories table.
--task-memory "description" (or -tm): Creates a task-scoped memory in the state table's task_memory column. Reviewed for promotion at task completion.
See run.md for the full workflow.
11. Logging
All logging goes to a single file: .taskmanager/logs/activity.log.
<timestamp> [<level>] [<command>] <message>
Levels: ERROR, DECISION. Logs are append-only.
Key state columns for session tracking: session_id in the state table.
12. Macro Architectural Analysis
During Phase 2 of planning, the AI performs a structured analysis of the PRD:
12.1 Tech Stack Detection
Scan the PRD content and codebase for technology indicators:
- Check
composer.json, package.json, requirements.txt, Gemfile, etc.
- Look for framework-specific files (e.g.,
artisan, next.config.js, nuxt.config.ts)
- Identify mentions of specific technologies in the PRD text
Store detected stack as JSON array in plan_analyses.tech_stack.
12.2 Ambiguity Detection
For each requirement in the PRD, assess:
- Is the requirement specific enough to implement without assumptions?
- Are there multiple valid interpretations?
- Are acceptance criteria implied but not stated?
Detected ambiguities feed into Phase 3 (Macro Architectural Questions).
12.3 Decision Storage
Decisions from Phase 3 are stored in two places:
plan_analyses.decisions — JSON array: [{question, answer, rationale, memory_id}]
memories table — Each decision becomes a memory with:
kind: as specified in the Macro Question Bank
importance: as specified in the Macro Question Bank
source_type: 'user'
source_via: 'taskmanager:plan:macro-questions'
confidence: 1.0
auto_updatable: 0
13. Cross-Cutting Concern Detection
During Phase 2, identify concerns that span multiple features:
Categories:
- Security — auth, input validation, CSRF, rate limiting, encryption
- Error handling — error boundaries, global exception handler, error reporting
- Monitoring — logging, metrics, health checks, alerting
- Performance — caching, lazy loading, pagination, query optimization
- Accessibility — ARIA, keyboard navigation, screen reader support
- Testing — test infrastructure, CI integration, coverage setup
- Documentation — API docs, developer guides, deployment docs
Task generation:
For each cross-cutting concern identified, generate a subtask under a dedicated "Cross-Cutting Concerns" epic. Each subtask should:
- Reference the epics it affects
- Have
moscow = 'must' or 'should' (concerns are rarely optional)
- Have appropriate
business_value based on impact
- Include
acceptance_criteria specific to the concern
14. Milestone Assignment Logic
MoSCoW to Milestone Mapping:
| MoSCoW | Milestone | phase_order | Description |
|---|
must | MS-001 | 1 | MVP / Core — required for launch |
should | MS-002 | 2 | Enhancement — important, post-MVP |
could | MS-003 | 3 | Nice-to-have — if time permits |
wont | (none) | — | Backlog — tasks created with status draft |
Inheritance rules:
- Epic-level tasks set the MoSCoW baseline for their subtasks
- Subtasks inherit
milestone_id from their parent unless explicitly overridden
- A subtask can have a different MoSCoW than its parent (e.g., a
could subtask under a must epic)
Milestone status derivation:
Milestone status is derived from its scoped tasks (plus milestone-level verification), not set independently:
planned — default, no tasks started
active — at least one scoped task is in-progress
completed — all scoped tasks are terminal (done, canceled, duplicate) and the milestone passes taskmanager:verify --milestone <id> against its acceptance_criteria
canceled — explicitly canceled by user
The v_milestone_status view (defined in schemas/schema.sql) backs display: for each milestone it reports total_tasks, terminal_tasks, and a derived_status (active if any scoped task is in-progress, completed if all scoped tasks are terminal and there is at least one, else planned). derived_status is for display only and does NOT mutate milestones.status — a milestone is only promoted to completed when all tasks are terminal AND milestone verification passes (see 8.2.1 and commands/verify.md).