# 🎯 How Taskr Actually Works

## 3.3 Tasks - The Building Blocks

### Understanding Task Hierarchy

Tasks are organized like an outline for a paper:

```
1.0 Build user authentication (parent task)
  1.1 Set up database tables (subtask)
    1.1.1 Create users table (sub-subtask)
    1.1.2 Add password hashing
  1.2 Create login page
    1.2.1 Design login form
    1.2.2 Add validation
  1.3 Implement logout
```

**The clever bit:** When all of 1.1.1 and 1.1.2 are done, 1.1 automatically completes. When all of 1.1, 1.2, and 1.3 are done, 1.0 completes itself!

### Task Types Explained

Each task has a type that tells your AI what kind of work it is:

- **setup** 🔧 - Getting things ready (installing packages, creating folders)
- **analysis** 🔍 - Figuring things out (researching APIs, planning approach)
- **implementation** 💻 - Actually building stuff (writing code, creating features)
- **validation** ✓ - Making sure it works (checking logic, reviewing code)
- **testing** 🧪 - Proving it works (writing tests, running test suites)

### Task Status Flow

Tasks move through statuses like a conveyor belt:

1. **open** ⭕ - Waiting to be started
2. **wip** 🔄 - Being worked on right now (work in progress)
3. **done** ✅ - Completed successfully
4. **skipped** ⏭️ - Intentionally skipped (not needed)

### The One-Task Rule

Here's something crucial: **Your AI can only work on ONE task at a time**.

Why? Because multitasking leads to confusion! When your AI marks a task as "wip," it gets exclusive ownership through a `wip_agent_id` field. No other agent can touch it, and this agent can't start another task until it finishes this one.

This is enforced in the database with PostgreSQL triggers and the MCP handler code!

### Creating New Tasks

Your AI creates tasks using the `create_task` tool:

```
Your AI: "I need to break this down into smaller pieces"
Creates: Subtasks under the current task, or a whole new task list
Speed: Instant
Control: Your AI decides the structure based on your requirements
```

**Tip:** For bigger projects, paste your requirements into your AI's chat first — it'll create a more thorough, well-structured task hierarchy.

### The Magic of `get_task`

When your AI calls `get_task`, here's what happens behind the scenes:

1. **Checks for existing WIP** - "Am I already working on something?"
2. **Looks for next logical task** - "What's the next 'open' task in order?"
3. **Marks it as WIP** - "This is mine now!"
4. **Returns full context** - Task details + notes + guidance rules
5. **Prevents conflicts** - No other agent can claim this task

The database function `get_task_for_agent` handles all this atomically!

---
