بنقرة واحدة
github-investigation-pattern
Cross-Tool Integration Pattern: GitHub Cross-Repository Investigation
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Cross-Tool Integration Pattern: GitHub Cross-Repository Investigation
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Generate comprehensive PR descriptions from project context and git changes
Framework for when to use Skills, Agents, or Patterns for organizing knowledge in the ADLC platform with decision criteria and migration strategies
Generate dbt model boilerplate with tests, documentation, and best practices
Validate documentation completeness and quality before project completion
Initialize new ADLC project with standard directory structure, documentation templates, and git branch
Complete reference for MCP tool integration across specialist and role agents including server inventory, tool recommendations, and security protocols
Pattern Type: Issue Investigation & Root Cause Analysis Tools: github-mcp, filesystem-mcp, sequential-thinking-mcp, dbt-mcp (optional) Confidence: HIGH (0.88) - Production-validated pattern Primary Users: github-sleuth-expert, qa-engineer-role, data-engineer-role
Scenario: Recurring error appearing across multiple repositories Challenge: Need to analyze pattern, understand root cause, recommend fix Goal: Comprehensive cross-repo investigation with actionable recommendations
github-mcp → Search issues across org (pattern discovery)
↓
github-mcp → Get detailed issue information (context gathering)
↓
filesystem-mcp → Read local repository code (root cause analysis)
↓
github-mcp → Search code across repos (pattern analysis)
↓
sequential-thinking-mcp → Systematic root cause analysis (complex bugs)
↓
github-sleuth-expert → Synthesize findings, recommend fix
↓
github-mcp → Document findings (issue comment or new issue)
Why multiple tools needed:
Search for similar issues across organization:
# 1. Search issues org-wide for error pattern
mcp__github__search_issues \
q="org:your-org type:issue state:open \"dbt test failure\"" \
per_page=50
Filter by specific error message:
# 2. Search for specific error text
mcp__github__search_issues \
q="org:your-org type:issue \"unique_key not defined\" in:body" \
per_page=30
Returns:
Analyze results for:
Get detailed information for each match:
# 3. Get issue details (repository A)
mcp__github__get_issue \
owner="your-org" \
repo="dbt_cloud" \
issue_number=123
# 4. Get issue details (repository B)
mcp__github__get_issue \
owner="your-org" \
repo="analytics-pipelines" \
issue_number=456
Extract from each issue:
For local repositories (filesystem-mcp):
# 5. Read affected file from local repo
mcp__filesystem__read_text_file \
path="/Users/TehFiestyGoat/GRC/dbt_cloud/models/marts/fct_orders.sql"
For remote repositories (github-mcp):
# 6. Get file contents from GitHub
mcp__github__get_file_contents \
owner="your-org" \
repo="dbt_cloud" \
path="models/marts/fct_orders.sql" \
branch="main"
Search for pattern in code:
# 7. Search code across org for similar patterns
mcp__github__search_code \
q="org:your-org incremental unique_key" \
per_page=20
Analyze code for:
unique_key)For complex, unclear root causes:
# 8. Use sequential thinking for systematic analysis
mcp__sequential-thinking__sequentialthinking \
thought="Define symptoms: 'unique_key not defined' errors in 5 repositories" \
thought_number=1 \
total_thoughts=10 \
next_thought_needed=true
Sequential thinking process:
Thought 1: Define symptoms and gather evidence
- 5 repositories affected
- All incremental models
- Error: "unique_key not defined"
- Started appearing after dbt 1.7 upgrade
Thought 2: Hypothesis A - Breaking change in dbt 1.7
- dbt 1.7 made unique_key mandatory for incremental models
- Previous versions allowed missing unique_key (defaulted to all columns)
Thought 3: Test Hypothesis A
- Check dbt 1.7 release notes (via github search)
- Verify affected models are all incremental
- Confirm all repos upgraded to dbt 1.7 in same timeframe
Thought 4: Evidence supports Hypothesis A
- dbt 1.7 release notes confirm breaking change
- All 5 repos upgraded to 1.7 within 2 weeks
- All affected models are incremental materialization
Thought 5: Hypothesis B (Alternative) - Configuration drift
- Templates updated but not applied retroactively
- New models have unique_key, old models don't
Thought 6: Compare hypotheses
- Hypothesis A: Breaking change (timing matches)
- Hypothesis B: Drift (timing doesn't match - all simultaneous)
- Hypothesis A more likely
Thought 7: Root cause identified
- dbt 1.7 breaking change made unique_key mandatory
- Existing incremental models without unique_key now fail
- Fix: Add unique_key to all incremental models
Thought 8: Validate solution approach
- Scan all incremental models for missing unique_key
- Add appropriate unique_key based on business logic
- Test each model after update
- Deploy fixes across all affected repos
Thought 9: No further analysis needed
- Root cause clear
- Solution straightforward
- High confidence in fix
Thought 10: COMPLETE
- Root cause: dbt 1.7 breaking change
- Solution: Add unique_key to all incremental models
- Confidence: HIGH (0.95)
Why sequential thinking valuable here:
Search for all affected incremental models:
# 9. Search for incremental models without unique_key
mcp__github__search_code \
q="org:your-org \"materialized='incremental'\" -unique_key" \
per_page=100
List all repositories with the issue:
# 10. List issues with same error across org
mcp__github__search_issues \
q="org:your-org type:issue state:open \"unique_key not defined\"" \
per_page=50
Identify pattern scope:
If dbt models involved:
# 11. Get model details to understand structure
mcp__dbt-mcp__get_model_details \
model_name="fct_orders"
# 12. Validate model health
mcp__dbt-mcp__get_model_health \
model_name="fct_orders"
Understand:
Add comprehensive comment to original issue:
# 13. Document root cause analysis
mcp__github__add_issue_comment \
owner="your-org" \
repo="dbt_cloud" \
issue_number=123 \
body="## Root Cause Analysis
**Issue**: unique_key not defined error in incremental models
**Root Cause**: dbt 1.7 breaking change
- dbt 1.7 made unique_key mandatory for incremental models
- Previous versions allowed missing unique_key (defaulted to all columns)
- All affected repos upgraded to dbt 1.7 within 2-week window
**Scope**:
- 5 repositories affected
- 23 incremental models require update
- Started after dbt 1.7 upgrade
**Solution**:
- Add unique_key configuration to all incremental models
- Base unique_key on business logic (primary key or composite)
- Add unique tests to validate key uniqueness
- Deploy fixes across all affected repos
**Implementation**:
- Created PR #456 with fixes for dbt_cloud repository
- Will create similar PRs for remaining 4 repositories
**Estimated Impact**:
- Fix complexity: Low (configuration change)
- Risk: Medium (production models)
- Timeline: 2-3 hours for all repos
"
Create tracking issue for each affected repo:
# 14. Create issue in repository B
mcp__github__create_issue \
owner="your-org" \
repo="analytics-pipelines" \
title="fix: Add unique_key to incremental models (dbt 1.7 breaking change)" \
body="## Issue
Incremental models failing with 'unique_key not defined' error after dbt 1.7 upgrade.
## Root Cause
dbt 1.7 breaking change - see dbt_cloud#123 for analysis.
## Solution
Add unique_key configuration to affected incremental models:
- int_customer_orders
- fct_transactions
- dim_products_scd
## Acceptance Criteria
- [ ] unique_key added to all incremental models
- [ ] unique tests added to validate key uniqueness
- [ ] dbt test passes
- [ ] Models build successfully
" \
labels=["bug", "dbt", "breaking-change"]
Step 1: Pattern Discovery (github-mcp)
mcp__github__search_issues \
q="org:your-org type:issue state:open \"duplicate records\" dbt test" \
per_page=50
Found:
Step 2: Detailed Analysis (github-mcp)
# Get details for each issue
mcp__github__get_issue owner="your-org" repo="dbt_cloud" issue_number=234
mcp__github__get_issue owner="your-org" repo="analytics-pipelines" issue_number=567
mcp__github__get_issue owner="your-org" repo="data-platform" issue_number=890
Common patterns:
merge strategyunique_key defined (not missing)Step 3: Code Analysis (filesystem-mcp + github-mcp)
# Read local affected model
mcp__filesystem__read_text_file \
path="/Users/TehFiestyGoat/GRC/dbt_cloud/models/marts/fct_customer_transactions.sql"
# Search for similar incremental patterns
mcp__github__search_code \
q="org:your-org incremental_strategy merge unique_key" \
per_page=30
Findings:
incremental_strategy='merge'unique_key (single column or composite)Step 4: Root Cause Analysis (sequential-thinking-mcp)
mcp__sequential-thinking__sequentialthinking
Systematic reasoning:
Thought 1: Symptoms - duplicates in incremental models with merge strategy
Thought 2: Hypothesis A - unique_key not actually unique in source data
Thought 3: Test A - Query source for duplicates... FOUND duplicates in source!
Thought 4: Hypothesis validated - source has duplicates, merge doesn't deduplicate
Thought 5: Why now? Source system change introduced duplicates 30 days ago
Thought 6: Solution - Add deduplication logic BEFORE merge
Thought 7: Implementation - Use ROW_NUMBER() window function to deduplicate
Thought 8: Validate - Test deduplication logic on sample data
Thought 9: Root cause confirmed - source duplicates + no deduplication = incremental duplicates
Thought 10: COMPLETE - High confidence solution
Root Cause: Source system introduced duplicates, dbt merge doesn't automatically deduplicate
Step 5: Solution Validation (dbt-mcp)
# Test deduplication logic
mcp__dbt-mcp__show sql_query="
WITH source_with_duplicates AS (
SELECT *,
ROW_NUMBER() OVER (
PARTITION BY transaction_id
ORDER BY updated_at DESC
) as row_num
FROM {{ ref('stg_transactions') }}
)
SELECT * FROM source_with_duplicates
WHERE row_num = 1
LIMIT 10
"
Validate deduplication works: Single record per transaction_id
Step 6: Document Findings (github-mcp)
# Add analysis to each affected issue
mcp__github__add_issue_comment \
owner="your-org" \
repo="dbt_cloud" \
issue_number=234 \
body="## Root Cause Identified
**Issue**: Duplicate records in incremental models
**Root Cause**: Source system introduced duplicates 30 days ago
- Source changed: Updated records now appear as new inserts
- dbt merge strategy: Does not automatically deduplicate
- Result: Both old and new records merged into table
**Cross-Repo Impact**: 3 repositories, 7 models affected
**Solution**: Add deduplication logic before merge
\`\`\`sql
WITH deduped_source AS (
SELECT *,
ROW_NUMBER() OVER (
PARTITION BY {{ unique_key }}
ORDER BY updated_at DESC
) as row_num
FROM source
)
SELECT * FROM deduped_source
WHERE row_num = 1
\`\`\`
**Implementation**: PR #789 created with fix
**Related Issues**:
- analytics-pipelines#567
- data-platform#890
"
github-mcp (search issues) → github-mcp (get details) →
filesystem-mcp (read code) → github-sleuth-expert (synthesize)
When: Clear error message, unknown root cause Tools: github-mcp for discovery, filesystem-mcp for code analysis
github-mcp (search related issues) → github-mcp (get PR history) →
filesystem-mcp (read changed files) → sequential-thinking (analyze causes) →
dbt-mcp/snowflake-mcp (validate hypothesis)
When: Performance regression, unclear trigger Tools: github-mcp for history, sequential-thinking for hypothesis testing
github-mcp (search org-wide) → filesystem-mcp (local analysis) →
github-mcp (code search) → sequential-thinking (pattern analysis) →
github-mcp (document findings)
When: Same issue in multiple repos, unclear common cause Tools: All 3 tools for comprehensive cross-repo analysis
github-mcp (get PR + files) → filesystem-mcp (read test files) →
dbt-mcp (get model health) → sequential-thinking (root cause) →
github-mcp (comment findings)
When: Test failing after PR merge, unclear which change caused it Tools: github-mcp for PR context, dbt-mcp for test execution
config/repositories.jsonpython3 scripts/resolve-repo-context.py <repo_name>Symptom: 500+ issues in search results, unclear which are relevant Solution: Use more specific search qualifiers
# Add date filter, specific repo, labels
mcp__github__search_issues \
q="org:your-org type:issue state:open created:>2025-09-01 label:bug \"dbt test\"" \
per_page=20
Symptom: Code search returns files without actual error Solution: Use more specific search terms, filter by file type
# Search .sql files only with exact phrase
mcp__github__search_code \
q="org:your-org \"unique_key not defined\" extension:sql" \
per_page=20
Symptom: Cannot read file from local repository Solution: Use github-mcp instead for remote file access
# Fall back to GitHub file contents
mcp__github__get_file_contents \
owner="your-org" \
repo="dbt_cloud" \
path="models/marts/fct_orders.sql"
Symptom: Systematic analysis doesn't identify clear root cause Solution: Gather more evidence with github-mcp and filesystem-mcp first
Delegates to github-sleuth-expert when:
github-sleuth-expert uses:
Uses this integration when:
Uses this integration when:
.claude/rules/github-repo-context-resolution.mdknowledge/mcp-servers/sequential-thinking/.claude/agents/specialists/github-sleuth-expert.mdCreated: 2025-10-08 Pattern Type: Cross-Tool Integration Confidence: HIGH (0.88) - Production-validated