# Knowledge (All Agents)

Create or update a knowledge document — decisions, notes, features, or product docs.

Read `flydocs/knowledge/README.md` for categories and guidance.
Read `flydocs/knowledge/INDEX.md` for existing entries.

## Procedure

### 1. Determine Intent

From user input or `$ARGUMENTS`, determine:

- **New doc** or **update existing doc**?
- **Category**: decision, feature, note, or product

If unclear, ask the user. Default to `note` for discoveries and learnings.

### 2. For New Docs

1. Read the template from `flydocs/knowledge/templates/<category>.md`
2. Gather content from the user — ask clarifying questions if context is thin
3. Fill in the frontmatter:
   - `title`: Descriptive, specific title
   - `created`: Today's date (`YYYY-MM-DD`)
   - `lastUpdated`: Today's date
   - `relatedIssues`: Any issue IDs discussed in this session
   - Category-specific fields (see template)
4. Write the doc to the correct directory:
   - Decisions: `flydocs/knowledge/decisions/NNN-title.md` (auto-increment NNN)
   - Features: `flydocs/knowledge/features/feature-name.md`
   - Notes: `flydocs/knowledge/notes/topic-name.md`
   - Product: `flydocs/knowledge/product/document-name.md`
5. Update `flydocs/knowledge/INDEX.md`:
   - Add entry to the appropriate table
   - Update the Quick Reference count
   - Use a concise description (helps agents assess relevance without loading the full doc)

### 3. For Existing Docs

1. Find the doc in INDEX.md or by searching `flydocs/knowledge/`
2. Read the current content
3. Apply the update
4. Update the `lastUpdated` field in frontmatter
5. Update the INDEX.md entry if the description changed

### 4. Confirm

Report what was created or updated:

- File path
- Category and title
- INDEX.md entry added/updated

## Triggers

- "document this" / "knowledge" / "add to knowledge base"
- "create an ADR" / "record this decision" / "capture this learning"
- "add a note about" / "document this discovery"

$ARGUMENTS
