|
15 | 15 |
|
16 | 16 | --- |
17 | 17 |
|
| 18 | +## PRD Guidelines |
| 19 | + |
| 20 | +When creating PRDs, use the template at [`PRDs/TEMPLATE.md`](./PRDs/TEMPLATE.md): |
| 21 | + |
| 22 | +1. **Study existing code first** - search for similar patterns, utilities, and implementations to reuse |
| 23 | +2. **Always start from the template** - maintains consistency across PRDs |
| 24 | +3. **Include architecture diagrams** - use ASCII art for overview, sequence, and dataflow diagrams |
| 25 | +4. **Use tables over prose** - easier to scan and maintain |
| 26 | +5. **Show Before/After code** - makes changes concrete in Problem Statement |
| 27 | +6. **Follow AGENTS.md exactly** - code examples must match original author style and test patterns |
| 28 | + |
| 29 | +### PRD Types and Focus Areas |
| 30 | + |
| 31 | +| Type | Focus | Key Sections | |
| 32 | +|------|-------|--------------| |
| 33 | +| Integration | API mapping, field translation, carrier quirks | Technical Design, Field Reference, Testing | |
| 34 | +| Refactoring | Architecture changes, migration strategy | Alternatives Considered, Migration & Rollback | |
| 35 | +| Enhancement | Additive features, enum extensions | Goals, Edge Cases, Backward Compatibility | |
| 36 | +| Architecture | System design, cross-cutting concerns | All sections, Security Considerations | |
| 37 | + |
| 38 | +### Required Sections (All PRDs) |
| 39 | + |
| 40 | +- Metadata block (table format) |
| 41 | +- Executive Summary with Key Architecture Decisions |
| 42 | +- Problem Statement with Current/Desired State code |
| 43 | +- Goals & Success Criteria (tables) |
| 44 | +- Alternatives Considered (decision table) |
| 45 | +- Technical Design with diagrams |
| 46 | +- Edge Cases & Failure Modes |
| 47 | +- Implementation Plan (phased tables) |
| 48 | +- Testing Strategy with code examples |
| 49 | +- Risk Assessment (table) |
| 50 | +- Migration & Rollback plan |
| 51 | + |
| 52 | +### Writing Style |
| 53 | + |
| 54 | +- Technical but accessible |
| 55 | +- Heavy use of tables over prose |
| 56 | +- Before/After code comparisons |
| 57 | +- No user stories - use technical specs with acceptance criteria |
| 58 | +- Bold for emphasis, inline code for technical terms |
| 59 | +- ASCII diagrams required: architecture overview, sequence diagrams, dataflow diagrams |
| 60 | + |
| 61 | +### Before Writing a PRD |
| 62 | + |
| 63 | +1. **Search the codebase** for similar implementations and patterns |
| 64 | +2. **Identify reusable utilities** in `karrio.lib`, `@karrio/hooks`, `@karrio/ui` |
| 65 | +3. **Study existing test files** in related modules for testing patterns |
| 66 | +4. **Document findings** in the "Existing Code Analysis" section |
| 67 | + |
| 68 | +### Interactive PRD Creation |
| 69 | + |
| 70 | +PRDs should be created iteratively with user input: |
| 71 | + |
| 72 | +1. **Draft** - Create initial structure with known information |
| 73 | +2. **Identify gaps** - Flag edge cases, ambiguities, and decision points |
| 74 | +3. **Ask questions** - Prompt user for clarification before finalizing architecture |
| 75 | +4. **Document decisions** - Record answers in "Open Questions & Decisions" section |
| 76 | +5. **Iterate** - Repeat until all decisions are resolved |
| 77 | + |
| 78 | +**When to ask clarifying questions:** |
| 79 | +- Multiple valid architectural approaches exist |
| 80 | +- Edge cases have no clear handling strategy |
| 81 | +- Trade-offs require business/product input |
| 82 | +- Scope boundaries are unclear |
| 83 | +- Backward compatibility decisions needed |
| 84 | + |
| 85 | +--- |
| 86 | + |
18 | 87 | ## Domain Context: Shipping & Logistics |
19 | 88 |
|
20 | 89 | Karrio is a **universal shipping API** that abstracts carrier integrations. Key domain concepts: |
@@ -266,6 +335,7 @@ import { |
266 | 335 | - ❌ **DO NOT** catch bare `Exception`—be specific |
267 | 336 | - ❌ **DO NOT** use mutable default arguments |
268 | 337 | - ❌ **DO NOT** import `*` except from designated re-export modules |
| 338 | +- ❌ **DO NOT** use raw SQL (`RunSQL`) in Django migrations—use only Django migration operations (`AddField`, `RemoveField`, `RenameField`, `AlterField`, `RunPython`, etc.) to ensure compatibility across SQLite, PostgreSQL, and MySQL |
269 | 339 |
|
270 | 340 | ### TypeScript/React |
271 | 341 | - ❌ **DO NOT** use `class` components—use functional components |
|
0 commit comments