### Revert Prompt Example for AI Code Source: https://lexler.github.io/augmented-coding-patterns/patterns/happy-to-delete An example prompt demonstrating how to instruct an AI to revert and retry code generation, specifically mentioning 'git reset --hard' to ensure a clean restart. This prompt structure helps the AI understand the need to discard previous attempts and apply new constraints. ```text Your solution [describe the problem]. A better approach would be [describe the better approach]. Please `git reset --hard` and try again. ``` -------------------------------- ### AI Interaction Example: Next.js 15 Auth Flow with Context7 Source: https://lexler.github.io/augmented-coding-patterns/patterns/jit-docs Demonstrates how an AI agent, using Context7, can search real-time Next.js 15 documentation to build an authentication flow, utilizing current APIs and patterns. ```text You: "Use context7 for Next.js, build auth flow" AI: Searches Next.js 15 docs in real-time AI: Finds current app router + middleware patterns AI: Generates code with actual current APIs ``` -------------------------------- ### AI Interaction Example: Internal API Convention Check Source: https://lexler.github.io/augmented-coding-patterns/patterns/jit-docs Illustrates how an AI agent can search internal project documentation to check and apply current API conventions and team standards. ```text You: "Check our API conventions doc" AI: Searches your docs for relevant patterns AI: Applies current team standards ``` -------------------------------- ### Bash Script for Counting Characters Source: https://lexler.github.io/augmented-coding-patterns/patterns/offload-deterministic This example demonstrates how to use a bash script, generated by AI, to reliably count occurrences of a specific character within a string. This approach is preferred over asking AI directly for counts due to AI's non-deterministic nature for such tasks. ```bash echo "strawberry" | grep -o "r" | wc -l ``` -------------------------------- ### Mixed Structured and Visual Log Example for Clue Calculation Source: https://lexler.github.io/augmented-coding-patterns/patterns/approved-logs This example illustrates an atypical use of the Approved Logs pattern with mixed structured and visual log data in a Markdown file. It includes sections for hidden solutions, player state (represented as ASCII grids), and debug information. A custom parser is required to interpret these domain-specific representations for validation, enhancing readability over raw data arrays. ```markdown === HIDDEN SOLUTION === ○ ○ ○ ● ○ ○ ● ● ● ○ ○ ● ● ○ ○ ● ● ● ○ ● ○ ○ ● ● ○ ● ○ ○ ○ ○ ○ ○ ○ === PLAYER STATE === × ○ ○ ○ × ○ ○ ○ ● × ○ ○ ○ × ○ ● ● ● × ○ ○ × ○ ○ ○ ● ○ × × × × × × === DEBUG INFO === Hovered Cell: {q: 0, r: 0} Directions: E_W: *3* 1 NW_SE: 1 *1* NE_SW: 3 === DEBUG INFO === Hovered Cell: {q: 1, r: 0} Directions: E_W: *3* 1 NW_SE: 3 NE_SW: *1* 2 ``` -------------------------------- ### Define MCP Tool Interface with Constraints (JSON) Source: https://lexler.github.io/augmented-coding-patterns/patterns/coerce-to-interface This JSON snippet defines an interface for an MCP tool named 'add_learning'. It specifies required string parameters like 'filename', 'title', 'topic', 'oneLiner', 'context', and 'examples', along with optional array parameters for 'tags' and 'related'. This enforces a strict structure for learning entries. ```json { "name": "add_learning", "parameters": { "filename": { "type": "string", "required": true }, "title": { "type": "string", "required": true }, "topic": { "type": "string", "required": true }, "oneLiner": { "type": "string", "required": true }, "context": { "type": "string", "required": true }, "examples": { "type": "string", "required": true }, "tags": { "type": "array", "items": { "type": "string" } }, "related": { "type": "array", "items": { "type": "string" } } } } ``` -------------------------------- ### Structured JSON Log Example for Payment Processing Source: https://lexler.github.io/augmented-coding-patterns/patterns/approved-logs This snippet demonstrates a typical structured JSON log format used for the Approved Logs pattern. It captures events during payment processing, including user details, discounts, and final amounts. The test runner parses the first line to initiate the process and compares subsequent logs against the entire file for validation. ```json {"event":"payment_processing", "user":"premium_member", "amount":1250} {"event":"discount_calculated", "discount_percent":20, "amount":250} {"event":"payment_completed", "final_amount":1000} ``` -------------------------------- ### Configure Context Markers for TDD Phases (Process Files) Source: https://lexler.github.io/augmented-coding-patterns/patterns/context-markers This configuration defines the starter characters for different phases of the Test-Driven Development (TDD) process. It assigns specific emojis for red, green, and refactoring states, each followed by a space. ```plaintext STARTER_CHARACTER = 🔴 for red test, 🌱 for green, 🌀 when refactoring, always followed by a space ``` -------------------------------- ### TypeScript Fixture for Inline Variable Refactoring (Input) Source: https://lexler.github.io/augmented-coding-patterns/patterns/approved-fixtures This TypeScript code snippet represents the input file for testing a refactoring operation, specifically inlining a variable. It includes a JSDoc comment with a command to guide the refactoring tool. ```typescript /** * @description Inline variable with multiple usages * @command refakts inline-variable "[{{CURRENT_FILE}} 8:18-8:21]" */ function processData(x: number, y: number): number { const sum = x + y; const result = sum * 2 + sum; return result; } ``` -------------------------------- ### Instruction Sandwich for Reliable AI Compliance Source: https://lexler.github.io/augmented-coding-patterns/patterns/reminders An enhanced method building on TODOs, where critical instructions are repeated at key points within the AI's workflow. This 'sandwich' approach significantly increases the likelihood of AI adhering to specific rules. ```markdown - [ ] Run tests. Ensure they are green - [ ] Implement feature A. Follow TDD - [ ] Run tests. Ensure they are green - [ ] Implement feature B - [ ] Run tests. Ensure they are green ``` -------------------------------- ### Set Ground Rules for Context Markers (User Level) Source: https://lexler.github.io/augmented-coding-patterns/patterns/context-markers This configuration sets the default starter character and stacking behavior for context markers in user-level ground rules. It ensures that replies always begin with a specified character and that stacked emojis are appended, not replaced. ```plaintext **ALWAYS** start replies with STARTER_CHARACTER + space (default: 🍀). Stack emojis when requested, don't replace. ``` -------------------------------- ### TODO List for AI Task Management Source: https://lexler.github.io/augmented-coding-patterns/patterns/reminders A simple checklist format to break down complex work into explicit steps for AI execution. This ensures AI systematically addresses each task, improving reliability. ```markdown - [ ] Run linter - [ ] Fix errors - [ ] Add tests - [ ] Update docs ```