# Task Context: Adding Pages

**Enforcement Tier: Guided**

You are adding new pages or features to an existing Decantr project. Guided mode enforces rules 1-5 (DNA) + 6, 7 (Blueprint).

---

## Enforced Rules

| # | Layer | Rule | Enforcement | What It Means |
|---|-------|------|-------------|---------------|
| 1 | DNA | **Style** | ENFORCED | You MUST use theme `terminal` |
| 2 | DNA | **Density** | ENFORCED | You MUST follow density `comfortable` |
| 3 | DNA | **Accessibility** | ENFORCED | You MUST meet WCAG level from essence |
| 4 | DNA | **Theme-mode** | ENFORCED | Theme/mode combination must be compatible |
| 5 | Blueprint | **Structure** | ENFORCED | Page MUST exist in essence before generating code |
| 6 | Blueprint | Layout | advisory | Pattern order is flexible |
| 7 | Blueprint | **Pattern-exists** | ENFORCED | All patterns must exist in the registry |

## Before You Start

### 1. Update the Essence

Before generating code for a new page, add it to the relevant section in the essence:

```json
{
  "blueprint": {
    "sections": [
      {
        "id": "section-id",
        "shell": "terminal-split",
        "pages": [
          // ... existing pages ...
          {
            "id": "new-page-id",
            "layout": ["pattern-1", "pattern-2"]
          }
        ]
      }
    ]
  }
}
```

### 2. Validate

Run validation to ensure the essence is valid:

```bash
npx @decantr/cli validate
```

### 3. Then Generate

Only after the page exists in the essence should you generate code for it.

## Checklist

Before adding a page:

- [ ] The page ID is added to the target `blueprint.sections[].pages[]` in essence
- [ ] The section has a `shell` defined
- [ ] The page has a `layout[]` with pattern IDs
- [ ] Validation passes (`npx @decantr/cli validate`)

During code generation:

- [ ] Use theme `terminal` for all styling
- [ ] Use theme `terminal` decorators for decoration
- [ ] Follow the shell structure for the target section (see section context file for shell notes)
- [ ] Include patterns from the layout array

After generation:

- [ ] Run `npx @decantr/cli validate`
- [ ] Verify the page matches the theme
- [ ] Check that the theme decorator styles are applied

## Violation Response

If the user asks you to generate a page that doesn't exist in the essence:

```
STOP: I cannot generate code for page "{{page}}" because it's not
in the essence blueprint. This would violate the Structure guard rule.

Would you like me to:
1. Add "{{page}}" to the essence first, then generate the code?
2. Skip this page for now?

Please confirm how you'd like to proceed.
```

**Never generate code for undefined pages.** Always update the essence first.

## Adding Features

When adding features (auth, search, payments, etc.):

1. Add the feature to `features[]` in the essence
2. Update relevant pages in `blueprint.sections[].pages[]`
3. Then implement the feature

## Pattern Selection

For new pages, suggest patterns based on page purpose:

| Page Type | Suggested Patterns |
|-----------|-------------------|
| Dashboard | `kpi-grid`, `chart-grid`, `data-table` |
| Settings | `form-sections`, `filter-bar` |
| Detail | `detail-header`, `activity-feed` |
| List | `data-table`, `filter-bar`, `card-grid` |
| Landing | `hero`, `cta-section`, `card-grid` |

---

*Task context generated by Decantr CLI*
