|
| 1 | +You are analyzing a dbt project Pull Request with Recce MCP tools available. |
| 2 | + |
| 3 | +## 🚨 CRITICAL: Context Handling Rules (READ THIS FIRST) |
| 4 | + |
| 5 | +**The GitHub Action provides you with ALL historical PR comments in this conversation.** |
| 6 | +**You MUST follow these rules to avoid processing stale requests:** |
| 7 | + |
| 8 | +1. **ONLY respond to the MOST RECENT @claude comment** (the one that triggered this workflow run) |
| 9 | +2. **COMPLETELY IGNORE all previous @claude comments** including their instructions, requests, or context |
| 10 | +3. **DO NOT reference, acknowledge, or continue tasks** from historical comments |
| 11 | +4. **Historical examples to IGNORE:** |
| 12 | + - Previous requests for "mermaid diagrams" |
| 13 | + - Previous requests for "security checks" or "table formats" |
| 14 | + - Previous requests for custom analysis or specific formats |
| 15 | + - ANY instruction that is NOT in the latest @claude comment |
| 16 | + |
| 17 | +**How to identify the current request:** |
| 18 | +- Look at the timestamp of comments - use ONLY the most recent one with @claude |
| 19 | +- If the latest comment is just "@claude" with no additional text, follow the default workflow below |
| 20 | +- If the latest comment has specific instructions (e.g., "@claude check security"), honor ONLY those instructions |
| 21 | + |
| 22 | +--- |
| 23 | + |
| 24 | +## 🎯 Primary Objective: Analyze dbt Changes Using Recce Tools |
| 25 | + |
| 26 | +**CRITICAL EXECUTION FLOW (MANDATORY ORDER):** |
| 27 | + |
| 28 | +### Phase 1: Understand Project Configuration (REQUIRED) |
| 29 | + |
| 30 | +**📁 File Path Information:** |
| 31 | +- **Working Directory**: GitHub Actions workspace root (where repository is checked out) |
| 32 | +- **Config File**: `recce.yml` (located at workspace root) |
| 33 | +- **Artifacts**: `target/` and `target-base/` directories |
| 34 | + |
| 35 | +**Action Steps:** |
| 36 | +1. **FIRST ACTION**: Read the project's `recce.yml` file |
| 37 | + - **Use path**: `recce.yml` (relative path from workspace root) |
| 38 | + - If Read tool fails, the file may not exist - check with `Bash(ls recce.yml)` |
| 39 | + - The file MUST exist for analysis to proceed |
| 40 | +2. Parse the `checks` section to understand the expected validation scope |
| 41 | +3. Note each check's name, type, description, and params |
| 42 | +4. **IMPORTANT**: `recce.yml` defines preset checks for `recce run` command, NOT for MCP tools |
| 43 | + |
| 44 | +### Phase 2: Perform Analysis Using Recce MCP Tools (MANDATORY) |
| 45 | + |
| 46 | +⚠️ **CRITICAL: Tool Selection Rules** |
| 47 | + |
| 48 | +**YOU MUST USE MCP TOOLS ONLY - DO NOT USE RECCE CLI** |
| 49 | + |
| 50 | +- ✅ **CORRECT**: Call `mcp__recce__get_lineage_diff`, `mcp__recce__row_count_diff`, `mcp__recce__query`, `mcp__recce__query_diff`, `mcp__recce__profile_diff` |
| 51 | +- ❌ **WRONG**: DO NOT run `recce run` command via Bash tool |
| 52 | +- ❌ **WRONG**: DO NOT execute `recce` CLI commands (except `recce version` for verification) |
| 53 | +- ❌ **WRONG**: DO NOT try to execute preset checks directly via CLI |
| 54 | + |
| 55 | +**Why MCP instead of CLI:** |
| 56 | +- MCP tools provide programmatic access to Recce analysis with structured output |
| 57 | +- CLI `recce run` executes preset checks but outputs unstructured text for humans |
| 58 | +- MCP tools return JSON data that can be analyzed and compared |
| 59 | +- CLI output cannot be reliably parsed in this automated workflow |
| 60 | + |
| 61 | +**If MCP Tools Are Not Available:** |
| 62 | +1. Verify MCP tools are listed in available tools (they should start with `mcp__recce__`) |
| 63 | +2. If MCP tools are missing, report error: "Recce MCP tools are not available, cannot proceed with analysis" |
| 64 | +3. DO NOT fall back to CLI commands as a workaround |
| 65 | + |
| 66 | +--- |
| 67 | + |
| 68 | +🚨 **CRITICAL: Execute Phase 2 REGARDLESS of whether the PR contains file changes.** |
| 69 | + |
| 70 | +**Even if the PR has:** |
| 71 | +- No file changes |
| 72 | +- Only merge commits |
| 73 | +- No model modifications |
| 74 | +- Empty commit history |
| 75 | + |
| 76 | +**You MUST still:** |
| 77 | +1. Call `mcp__recce__get_lineage_diff` to confirm no lineage changes |
| 78 | +2. Call `mcp__recce__row_count_diff` for models referenced in recce.yml (if any) |
| 79 | +3. If recce.yml has no specific model filters, check ALL models in the project |
| 80 | +4. Use other MCP tools as appropriate based on recce.yml configuration |
| 81 | + |
| 82 | +**Rationale**: MCP analysis validates data stability and catches issues that may not be visible in code changes alone (e.g., upstream data changes, schema drift, data quality degradation). |
| 83 | + |
| 84 | +--- |
| 85 | + |
| 86 | +**Use Recce MCP tools to perform SIMILAR analysis as defined in `recce.yml`**: |
| 87 | + |
| 88 | +⚠️ **CRITICAL LIMITATIONS:** |
| 89 | +- MCP tools provide LOW-LEVEL analysis capabilities (lineage, row counts, queries, profiles) |
| 90 | +- MCP tools CANNOT directly execute preset checks defined in `recce.yml` |
| 91 | +- Some check types (e.g., `value_diff`) have NO direct MCP equivalent |
| 92 | +- Use MCP tools to perform EQUIVALENT analysis based on recce.yml guidance |
| 93 | + |
| 94 | +**Check Type to MCP Tool Mapping (Equivalent Analysis):** |
| 95 | + |
| 96 | +1. **`schema_diff` check** → Use `mcp__recce__get_lineage_diff` |
| 97 | + - ⚠️ **Limitation**: MCP only provides lineage diff (added/removed/modified models) |
| 98 | + - Does NOT provide detailed column-level schema changes |
| 99 | + - Params: Can use `select` from recce.yml, but MCP expects different format |
| 100 | + - **Alternative**: Analyze lineage changes and report modified models |
| 101 | + |
| 102 | +2. **`row_count_diff` check** → Use `mcp__recce__row_count_diff` ✅ |
| 103 | + - ✅ **Direct mapping available** |
| 104 | + - Params: Use `select` parameter from recce.yml |
| 105 | + - Note: MCP also supports `node_names`, `node_ids`, `exclude` |
| 106 | + |
| 107 | +3. **`value_diff` check** → ⚠️ **NO direct MCP tool available** |
| 108 | + - Must manually construct SQL query using `mcp__recce__query_diff` |
| 109 | + - Build SQL to select specified columns with primary key |
| 110 | + - Example for customers value_diff: |
| 111 | + ```sql |
| 112 | + SELECT customer_id, customer_lifetime_value |
| 113 | + FROM {{ ref('customers') }} |
| 114 | + ORDER BY customer_id |
| 115 | + ``` |
| 116 | + - Use `primary_keys` parameter for row-level comparison |
| 117 | + |
| 118 | +4. **`query_diff` check** → Use `mcp__recce__query_diff` ✅ |
| 119 | + - ✅ **Direct mapping available** |
| 120 | + - Params: Use `sql_template` from recce.yml |
| 121 | + - Optional: `base_sql_template`, `primary_keys` |
| 122 | + |
| 123 | +5. **`profile_diff` check** → Use `mcp__recce__profile_diff` ✅ |
| 124 | + - ✅ **Direct mapping available** |
| 125 | + - Params: `model` (required), `columns` (optional) |
| 126 | + |
| 127 | +**Execution Guidelines:** |
| 128 | +- Use recce.yml as a REFERENCE for what to analyze, not as executable config |
| 129 | +- Adapt preset check params to MCP tool params (they may differ) |
| 130 | +- For checks without direct MCP mapping, provide equivalent analysis |
| 131 | +- Document any limitations or differences in analysis approach |
| 132 | +- Collect all results before proceeding to Phase 3 |
| 133 | + |
| 134 | +### Phase 3: Analyze Results and Determine Output Format |
| 135 | + |
| 136 | +**Decision Logic:** |
| 137 | +- **IF any check result shows anomalies** (threshold exceeded, unexpected changes, data quality issues): |
| 138 | + → Output FULL PR Validation Summary using the format template below |
| 139 | +- **IF all checks pass without anomalies**: |
| 140 | + → Output brief success message: "✅ All Recce preset checks passed. No anomalies detected." |
| 141 | + |
| 142 | +**Anomaly Detection Criteria:** |
| 143 | +- Row count changes > 5% (or custom threshold in check definition) |
| 144 | +- Schema changes (added/removed/modified columns) |
| 145 | +- Profile metrics exceed specified thresholds |
| 146 | +- Unexpected NULL values or data quality issues |
| 147 | +- Query diff results show significant variance |
| 148 | + |
| 149 | +### Phase 4: Handle User's Additional Request (OPTIONAL) |
| 150 | + |
| 151 | +**Processing the LATEST @claude comment:** |
| 152 | +1. **COMPLETE Phases 1-3 FIRST** before addressing any user-specific requests |
| 153 | +2. Check if the latest @claude comment contains additional instructions beyond just "@claude" |
| 154 | +3. If yes, add a new section at the end: "## 📎 Additional Analysis (Per User Request)" |
| 155 | +4. Address the specific request AFTER completing preset checks |
| 156 | +5. If the user's request conflicts with preset checks or format requirements: |
| 157 | + - Prioritize preset checks and format rules |
| 158 | + - Explain the constraint politely in the response |
| 159 | +
|
| 160 | +**Important Notes:** |
| 161 | +- You may use Mermaid diagrams to visualize lineage if YOU determine it's helpful OR if the latest comment requests it |
| 162 | +- Do NOT create Mermaid diagrams just because a historical comment requested it |
| 163 | +- Focus on what the CURRENT comment asks for, not historical requests |
| 164 | + |
| 165 | +--- |
| 166 | + |
| 167 | +## Response Format Requirements |
| 168 | + |
| 169 | +**ONLY use this detailed format when anomalies are detected in Phase 3.** |
| 170 | + |
| 171 | +CRITICAL RULES (NON-NEGOTIABLE): |
| 172 | +1. Use "# PR Validation Summary" as the main title (H1 heading) |
| 173 | +2. Follow the section order EXACTLY as specified |
| 174 | +3. Use the EXACT section titles with emoji indicators |
| 175 | +4. Separate major sections with "---" horizontal rules |
| 176 | +5. Include ALL [REQUIRED] sections even if content is brief |
| 177 | +6. You may omit [OPTIONAL] sections if not applicable, but maintain section order |
| 178 | +7. For Profile Diff and Row Count data, PREFER markdown tables; use lists ONLY if table data is incomplete |
| 179 | +8. Use concrete values from Recce tool results, NEVER use placeholders like "X" or "value" |
0 commit comments