You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

step-05-patterns.md 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. # Step 5: Implementation Patterns & Consistency Rules
  2. ## MANDATORY EXECUTION RULES (READ FIRST):
  3. - 🛑 NEVER generate content without user input
  4. - 📖 CRITICAL: ALWAYS read the complete step file before taking any action - partial understanding leads to incomplete decisions
  5. - 🔄 CRITICAL: When loading next step with 'C', ensure the entire file is read and understood before proceeding
  6. - ✅ ALWAYS treat this as collaborative discovery between architectural peers
  7. - 📋 YOU ARE A FACILITATOR, not a content generator
  8. - 💬 FOCUS on patterns that prevent AI agent implementation conflicts
  9. - 🎯 EMPHASIZE what agents could decide DIFFERENTLY if not specified
  10. - ⚠️ ABSOLUTELY NO TIME ESTIMATES - AI development speed has fundamentally changed
  11. - ✅ YOU MUST ALWAYS SPEAK OUTPUT In your Agent communication style with the config `{communication_language}`
  12. ## EXECUTION PROTOCOLS:
  13. - 🎯 Show your analysis before taking any action
  14. - 🎯 Focus on consistency, not implementation details
  15. - ⚠️ Present A/P/C menu after generating patterns content
  16. - 💾 ONLY save when user chooses C (Continue)
  17. - 📖 Update frontmatter `stepsCompleted: [1, 2, 3, 4, 5]` before loading next step
  18. - 🚫 FORBIDDEN to load next step until C is selected
  19. ## COLLABORATION MENUS (A/P/C):
  20. This step will generate content and present choices:
  21. - **A (Advanced Elicitation)**: Use discovery protocols to develop comprehensive consistency patterns
  22. - **P (Party Mode)**: Bring multiple perspectives to identify potential conflict points
  23. - **C (Continue)**: Save the patterns and proceed to project structure
  24. ## PROTOCOL INTEGRATION:
  25. - When 'A' selected: Invoke the `bmad-advanced-elicitation` skill
  26. - When 'P' selected: Invoke the `bmad-party-mode` skill
  27. - PROTOCOLS always return to display this step's A/P/C menu after the A or P have completed
  28. - User accepts/rejects protocol changes before proceeding
  29. ## CONTEXT BOUNDARIES:
  30. - Core architectural decisions from step 4 are complete
  31. - Technology stack is decided and versions are verified
  32. - Focus on HOW agents should implement, not WHAT they should implement
  33. - Consider what could vary between different AI agents
  34. ## YOUR TASK:
  35. Define implementation patterns and consistency rules that ensure multiple AI agents write compatible, consistent code that works together seamlessly.
  36. ## PATTERNS DEFINITION SEQUENCE:
  37. ### 1. Identify Potential Conflict Points
  38. Based on the chosen technology stack and decisions, identify where AI agents could make different choices:
  39. **Naming Conflicts:**
  40. - Database table/column naming conventions
  41. - API endpoint naming patterns
  42. - File and directory naming
  43. - Component/function/variable naming
  44. - Route parameter formats
  45. **Structural Conflicts:**
  46. - Where tests are located
  47. - How components are organized
  48. - Where utilities and helpers go
  49. - Configuration file organization
  50. - Static asset organization
  51. **Format Conflicts:**
  52. - API response wrapper formats
  53. - Error response structures
  54. - Date/time formats in APIs and UI
  55. - JSON field naming conventions
  56. - API status code usage
  57. **Communication Conflicts:**
  58. - Event naming conventions
  59. - Event payload structures
  60. - State update patterns
  61. - Action naming conventions
  62. - Logging formats and levels
  63. **Process Conflicts:**
  64. - Loading state handling
  65. - Error recovery patterns
  66. - Retry implementation approaches
  67. - Authentication flow patterns
  68. - Validation timing and methods
  69. ### 2. Facilitate Pattern Decisions
  70. For each conflict category, facilitate collaborative pattern definition:
  71. **Present the Conflict Point:**
  72. "Given that we're using {{tech_stack}}, different AI agents might handle {{conflict_area}} differently.
  73. For example, one agent might name database tables 'users' while another uses 'Users' - this would cause conflicts.
  74. We need to establish consistent patterns that all agents follow."
  75. **Show Options and Trade-offs:**
  76. "Common approaches for {{pattern_category}}:
  77. 1. {{option_1}} - {{pros_and_cons}}
  78. 2. {{option_2}} - {{pros_and_cons}}
  79. 3. {{option_3}} - {{pros_and_cons}}
  80. Which approach makes the most sense for our project?"
  81. **Get User Decision:**
  82. "What's your preference for this pattern? (or discuss the trade-offs more)"
  83. ### 3. Define Pattern Categories
  84. #### Naming Patterns
  85. **Database Naming:**
  86. - Table naming: users, Users, or user?
  87. - Column naming: user_id or userId?
  88. - Foreign key format: user_id or fk_user?
  89. - Index naming: idx_users_email or users_email_index?
  90. **API Naming:**
  91. - REST endpoint naming: /users or /user? Plural or singular?
  92. - Route parameter format: :id or {id}?
  93. - Query parameter naming: user_id or userId?
  94. - Header naming conventions: X-Custom-Header or Custom-Header?
  95. **Code Naming:**
  96. - Component naming: UserCard or user-card?
  97. - File naming: UserCard.tsx or user-card.tsx?
  98. - Function naming: getUserData or get_user_data?
  99. - Variable naming: userId or user_id?
  100. #### Structure Patterns
  101. **Project Organization:**
  102. - Where do tests live? **tests**/ or \*.test.ts co-located?
  103. - How are components organized? By feature or by type?
  104. - Where do shared utilities go?
  105. - How are services and repositories organized?
  106. **File Structure:**
  107. - Config file locations and naming
  108. - Static asset organization
  109. - Documentation placement
  110. - Environment file organization
  111. #### Format Patterns
  112. **API Formats:**
  113. - API response wrapper? {data: ..., error: ...} or direct response?
  114. - Error format? {message, code} or {error: {type, detail}}?
  115. - Date format in JSON? ISO strings or timestamps?
  116. - Success response structure?
  117. **Data Formats:**
  118. - JSON field naming: snake_case or camelCase?
  119. - Boolean representations: true/false or 1/0?
  120. - Null handling patterns
  121. - Array vs object for single items
  122. #### Communication Patterns
  123. **Event Systems:**
  124. - Event naming convention: user.created or UserCreated?
  125. - Event payload structure standards
  126. - Event versioning approach
  127. - Async event handling patterns
  128. **State Management:**
  129. - State update patterns: immutable updates or direct mutation?
  130. - Action naming conventions
  131. - Selector patterns
  132. - State organization principles
  133. #### Process Patterns
  134. **Error Handling:**
  135. - Global error handling approach
  136. - Error boundary patterns
  137. - User-facing error message format
  138. - Logging vs user error distinction
  139. **Loading States:**
  140. - Loading state naming conventions
  141. - Global vs local loading states
  142. - Loading state persistence
  143. - Loading UI patterns
  144. ### 4. Generate Patterns Content
  145. Prepare the content to append to the document:
  146. #### Content Structure:
  147. ```markdown
  148. ## Implementation Patterns & Consistency Rules
  149. ### Pattern Categories Defined
  150. **Critical Conflict Points Identified:**
  151. {{number_of_potential_conflicts}} areas where AI agents could make different choices
  152. ### Naming Patterns
  153. **Database Naming Conventions:**
  154. {{database_naming_rules_with_examples}}
  155. **API Naming Conventions:**
  156. {{api_naming_rules_with_examples}}
  157. **Code Naming Conventions:**
  158. {{code_naming_rules_with_examples}}
  159. ### Structure Patterns
  160. **Project Organization:**
  161. {{project_structure_rules_with_examples}}
  162. **File Structure Patterns:**
  163. {{file_organization_rules_with_examples}}
  164. ### Format Patterns
  165. **API Response Formats:**
  166. {{api_response_structure_rules}}
  167. **Data Exchange Formats:**
  168. {{data_format_rules_with_examples}}
  169. ### Communication Patterns
  170. **Event System Patterns:**
  171. {{event_naming_and_structure_rules}}
  172. **State Management Patterns:**
  173. {{state_update_and_organization_rules}}
  174. ### Process Patterns
  175. **Error Handling Patterns:**
  176. {{consistent_error_handling_approaches}}
  177. **Loading State Patterns:**
  178. {{loading_state_management_rules}}
  179. ### Enforcement Guidelines
  180. **All AI Agents MUST:**
  181. - {{mandatory_pattern_1}}
  182. - {{mandatory_pattern_2}}
  183. - {{mandatory_pattern_3}}
  184. **Pattern Enforcement:**
  185. - How to verify patterns are followed
  186. - Where to document pattern violations
  187. - Process for updating patterns
  188. ### Pattern Examples
  189. **Good Examples:**
  190. {{concrete_examples_of_correct_pattern_usage}}
  191. **Anti-Patterns:**
  192. {{examples_of_what_to_avoid}}
  193. ```
  194. ### 5. Present Content and Menu
  195. Show the generated patterns content and present choices:
  196. "I've documented implementation patterns that will prevent conflicts between AI agents working on this project.
  197. **Here's what I'll add to the document:**
  198. [Show the complete markdown content from step 4]
  199. **What would you like to do?**
  200. [A] Advanced Elicitation - Explore additional consistency patterns
  201. [P] Party Mode - Review patterns from different implementation perspectives
  202. [C] Continue - Save these patterns and move to project structure"
  203. ### 6. Handle Menu Selection
  204. #### If 'A' (Advanced Elicitation):
  205. - Invoke the `bmad-advanced-elicitation` skill with current patterns
  206. - Process enhanced consistency rules that come back
  207. - Ask user: "Accept these additional pattern refinements? (y/n)"
  208. - If yes: Update content, then return to A/P/C menu
  209. - If no: Keep original content, then return to A/P/C menu
  210. #### If 'P' (Party Mode):
  211. - Invoke the `bmad-party-mode` skill with implementation patterns context
  212. - Process collaborative insights about potential conflicts
  213. - Ask user: "Accept these changes to the implementation patterns? (y/n)"
  214. - If yes: Update content, then return to A/P/C menu
  215. - If no: Keep original content, then return to A/P/C menu
  216. #### If 'C' (Continue):
  217. - Append the final content to `{planning_artifacts}/architecture.md`
  218. - Update frontmatter: `stepsCompleted: [1, 2, 3, 4, 5]`
  219. - Load `./step-06-structure.md`
  220. ## APPEND TO DOCUMENT:
  221. When user selects 'C', append the content directly to the document using the structure from step 4.
  222. ## SUCCESS METRICS:
  223. ✅ All potential AI agent conflict points identified and addressed
  224. ✅ Comprehensive patterns defined for naming, structure, and communication
  225. ✅ Concrete examples provided for each pattern
  226. ✅ Enforcement guidelines clearly documented
  227. ✅ User collaborated on pattern decisions rather than receiving recommendations
  228. ✅ A/P/C menu presented and handled correctly
  229. ✅ Content properly appended to document when C selected
  230. ## FAILURE MODES:
  231. ❌ Missing potential conflict points that could cause agent conflicts
  232. ❌ Being too prescriptive about implementation details instead of focusing on consistency
  233. ❌ Not providing concrete examples for each pattern
  234. ❌ Failing to address cross-cutting concerns like error handling
  235. ❌ Not considering the chosen technology stack when defining patterns
  236. ❌ Not presenting A/P/C menu after content generation
  237. ❌ **CRITICAL**: Reading only partial step file - leads to incomplete understanding and poor decisions
  238. ❌ **CRITICAL**: Proceeding with 'C' without fully reading and understanding the next step file
  239. ❌ **CRITICAL**: Making decisions without complete understanding of step requirements and protocols
  240. ## NEXT STEP:
  241. After user selects 'C' and content is saved to document, load `./step-06-structure.md` to define the complete project structure.
  242. Remember: Do NOT proceed to step-06 until user explicitly selects 'C' from the A/P/C menu and content is saved!