# Chat Source Tracking Process

When responding to product chat messages, track and include sources for transparency.

## Source Format

```yaml
sources:
  - file: "brain.md"           # Relative to product folder
    lines: [12, 45]            # Start and end line (optional)
    snippet: "The product..."  # Relevant excerpt (50-150 chars)
    relevance: 0.92            # 0-1 score (how relevant to the response)
```

## When to Track Sources

Track sources when your response:
- References product context (brain.md, brief.md, PRD, etc.)
- Makes decisions based on design guidelines
- Quotes or paraphrases from product docs
- Uses information from target-market.md, personas, etc.

## Relevance Scoring

| Score | Meaning |
|-------|---------|
| 0.9-1.0 | Directly quoted or primary basis for response |
| 0.7-0.9 | Heavily influenced the response |
| 0.5-0.7 | Provided context |
| 0.3-0.5 | Background reference |
| <0.3 | Minor/tangential |

## Files to Consider

Common product files to track:
- `brain.md` - Product intelligence
- `brief.md` - Product brief
- `product.yaml` - Configuration
- `discovery/prd.md` - Requirements
- `discovery/target-market.md` - Audience
- `discovery/competitive-analysis.md` - Competition
- `design/brand-guidelines.md` - Brand
- `design/design-system-prompt.md` - Design rules
- `build/tech-stack.md` - Technical decisions

## Example Response with Sources

```yaml
- id: msg-123
  role: assistant
  content: "Based on your target market of busy professionals..."
  timestamp: "2026-02-18T04:45:00Z"
  sources:
    - file: "discovery/target-market.md"
      lines: [5, 20]
      snippet: "Primary audience: busy professionals aged 25-45 who value time efficiency"
      relevance: 0.95
    - file: "brain.md"
      lines: [45, 52]
      snippet: "Core value proposition centers on saving users 2+ hours per week"
      relevance: 0.85
```

## Implementation

When processing a chat job:

1. **Before responding:** Note which files you read
2. **While reading:** Extract relevant snippets (keep under 150 chars)
3. **After drafting:** Score relevance of each source
4. **When writing to chat.yaml:** Include `sources` array

## Quick Template

```yaml
sources:
  - file: "<relative-path>"
    lines: [<start>, <end>]
    snippet: "<relevant excerpt>"
    relevance: <0.0-1.0>
```
