iterative-code-exploration
Progressive context retrieval pattern for understanding unfamiliar codebases through iterative refinement
What this skill does
# Iterative Code Exploration A systematic pattern for progressively exploring and understanding unfamiliar codebases through iterative context refinement. ## The Problem When working with new codebases, you often don't know: - Which files contain relevant code - What patterns and conventions exist - What terminology the project uses - How components interact Standard approaches fail: - **Read everything**: Time-consuming and overwhelming - **Guess locations**: Often misses critical context - **Ask broad questions**: Returns too much irrelevant information ## The Solution: 4-Phase Iterative Loop ``` ┌─────────────────────────────────────────────┐ │ │ │ ┌──────────┐ ┌──────────┐ │ │ │ DISCOVER │─────▶│ EVALUATE │ │ │ └──────────┘ └──────────┘ │ │ ▲ │ │ │ │ ▼ │ │ ┌──────────┐ ┌──────────┐ │ │ │ LOOP │◀─────│ REFINE │ │ │ └──────────┘ └──────────┘ │ │ │ │ Max 3-4 cycles, then synthesize │ └─────────────────────────────────────────────┘ ``` ### Phase 1: DISCOVER Start with broad exploration: ```bash # Find entry points find . -name "main.*" -o -name "index.*" -o -name "app.*" | head -20 # Discover project structure tree -L 3 -I 'node_modules|dist|build' # Find configuration find . -name "*.config.*" -o -name "package.json" -o -name "*.toml" # Identify key patterns grep -r "export class" --include="*.ts" src/ | head -20 grep -r "def " --include="*.py" . | head -20 ``` Document initial findings: - Project type (web app, library, service, etc.) - Tech stack (languages, frameworks) - Architecture hints (monorepo, microservices, etc.) ### Phase 2: EVALUATE Assess discovered files for relevance: ```bash # Read high-value files cat README.md cat ARCHITECTURE.md 2>/dev/null cat docs/overview.md 2>/dev/null # Check package manifests cat package.json | jq '.dependencies, .scripts' cat Cargo.toml 2>/dev/null cat requirements.txt 2>/dev/null ``` **Scoring Criteria:** - **Critical (★★★)**: Entry points, core logic, main configs - **Important (★★)**: Utilities, shared components, types - **Supporting (★)**: Tests, docs, examples - **Noise (-)**: Generated files, vendored code ### Phase 3: REFINE Focus on specific areas identified as relevant: ```bash # Dive into specific modules ls -la src/core/ cat src/core/index.ts # Trace dependencies grep -r "import.*from.*core" --include="*.ts" src/ | head -20 # Find related patterns grep -A 5 -B 5 "class UserService" src/**/*.ts # Check tests for usage examples find . -name "*.test.*" -o -name "*.spec.*" | head -10 ``` Build mental model: - How components connect - What patterns are used consistently - Where similar functionality lives ### Phase 4: LOOP Decision point - do you need more context? **Continue if:** - Key functionality still unclear - Dependencies not fully traced - Patterns inconsistent or confusing **Stop if:** - Core logic understood - Can explain main flows - Ready to make changes confidently ## Practical Workflow ### For Feature Implementation 1. **Discover**: Find similar existing features ```bash grep -r "feature-name" src/ find . -name "*feature*" ``` 2. **Evaluate**: Review implementation patterns ```bash cat src/features/similar-feature/index.ts ``` 3. **Refine**: Check tests and edge cases ```bash cat src/features/similar-feature/*.test.ts ``` 4. **Loop**: Trace dependencies until clear ### For Bug Fixing 1. **Discover**: Locate error origin ```bash grep -r "error message" src/ git log -S "error message" ``` 2. **Evaluate**: Understand surrounding context ```bash cat path/to/file.ts | grep -A 20 -B 20 "error location" ``` 3. **Refine**: Check call sites and callers ```bash grep -r "functionName" --include="*.ts" src/ ``` 4. **Loop**: Expand context as needed ### For Refactoring 1. **Discover**: Map current structure ```bash find src/ -name "*.ts" | xargs wc -l | sort -n grep -r "class\|interface" --include="*.ts" src/ | wc -l ``` 2. **Evaluate**: Identify coupling points ```bash grep -r "import.*from.*module" src/ | cut -d: -f2 | sort | uniq -c | sort -rn ``` 3. **Refine**: Find all usages ```bash grep -r "ComponentName" --include="*.ts" src/ ``` 4. **Loop**: Ensure all references found ## Output Template After each loop iteration, document: ```markdown ## Iteration N **Query**: What I was looking for **Found**: X files, Y patterns, Z components **Relevance**: High/Medium/Low with reasons **Gaps**: What's still unclear **Next**: What to explore in next iteration **Key Files**: - path/to/file.ts - Core implementation (★★★) - path/to/other.ts - Supporting utility (★★) **Mental Model Update**: - New understanding of X - Connection between Y and Z - Pattern: Description ``` ## Integration Points Complements: - **knowledge-architecture**: For documenting discoveries - **second-brain-librarian**: For saving exploration notes - **project-orchestration**: For planning exploration strategy - **testing-patterns**: For learning through tests ## Tips - Start wide, then narrow focus - Document assumptions to validate - Use tests as documentation - Follow imports/exports - Check git history for context - Look for comments explaining "why"
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.