investigating-code-patterns

2
0
Source

Systematically trace code flows, locate implementations, diagnose performance issues, and map system architecture. Use when understanding how existing systems work, researching concepts, exploring code structure, or answering "how/where/why is X implemented?" questions.

Install

mkdir -p .claude/skills/investigating-code-patterns && curl -L -o skill.zip "https://mcp.directory/api/skills/download/3906" && unzip -o skill.zip -d .claude/skills/investigating-code-patterns && rm skill.zip

Installs to .claude/skills/investigating-code-patterns

About this skill

Investigating Code Patterns

When to Use This Skill

  • Understanding how existing systems work end-to-end
  • Researching concepts or technologies in your codebase
  • Exploring code structure, patterns, and dependencies
  • Answering "how/where/what" questions about implementations
  • NOT for building new features (use implementation skills for that)

Core Investigation Types

1. Code Flow: "How does X work?"

Trace execution end-to-end from entry point to outcome.

Steps:

  1. Find the entry point (API endpoint, component, function)
  2. Trace function calls and data transformations
  3. Follow imports and dependencies
  4. Identify key decision points and error handling

2. Code Location: "Where is X implemented?"

Find where functionality lives in the codebase.

Steps:

  1. Search for relevant keywords using grep
  2. Check related files and modules
  3. Identify main implementation and supporting files
  4. Verify entry points and usage patterns

3. Performance Analysis: "Why is X slow?"

Diagnose bottlenecks using 3-phase approach.

Phase 1: Locate bottleneck

  • Find entry point where slowness occurs
  • Trace execution path
  • Identify all operations (DB queries, API calls, compute, I/O)
  • Look for obvious issues: N+1 queries, nested loops, large payloads

Phase 2: Root cause (if unclear)

  • Generate hypotheses ranked by likelihood
  • Validate with evidence from code

Phase 3: Fix or instrument

  • If fix clear → implement optimization
  • If uncertain → add logging/profiling for user testing

Common performance patterns:

PatternSymptomsFix Direction
N+1 queriesSequential DB callsBatch/eager loading
Algorithmic complexityGrows with dataOptimize algorithm
Large payloadNetwork time highPagination/filtering
Missing cacheSame data fetched repeatedlyAdd caching
Sequential operationsWaits in seriesParallelize

4. Architecture Mapping: "How is X structured?"

Understand system organization, components, and integration points.

Steps:

  1. Map component boundaries and responsibilities
  2. Identify data flow patterns between layers
  3. Document integration points and dependencies
  4. Trace external service interactions

Investigation Strategy

Start with Documentation

Read in this order:

  1. docs/product-requirements.md — project overview and features (F-##)
  2. docs/feature-spec/F-##-*.md — technical details
  3. docs/system-design.md — architecture
  4. docs/api-contracts.yaml — API reference

Choose Your Tools

For known file paths:

  • Read — examine specific files directly

For pattern searches:

  • Grep — find exact text matches (function names, imports, error messages)
  • Glob — discover files by name pattern

For semantic queries:

  • Launch Explore agent for complex, multi-file pattern discovery
  • Use senior-engineer agent for subtle performance bottlenecks

Parallel Investigation

Launch 2-4 independent agents for large codebases:

Full-stack flow:

  • Agent 1: Frontend (UI, state, API calls)
  • Agent 2: Backend (endpoints, services, database)
  • Agent 3: Integration (tests, config, external APIs)

Multi-service architecture:

  • Agent 1: Auth (authentication, tokens)
  • Agent 2: User service (profile, sync)
  • Agent 3: Authorization (permissions, RBAC)

Performance issues:

  • Agent 1: Frontend perf (renders, bundle, assets)
  • Agent 2: API/network (queries, payloads, caching)
  • Agent 3: Backend perf (algorithms, database, services)

Documenting Findings

Code Flow Template

## How [Feature] Works

### Purpose
[Brief description and why it exists]

### High-Level Flow
1. User action triggers [component/function] (file:line)
2. [Step 2 with file:line reference]
3. [Step 3 with file:line reference]
4. Final outcome

### Key Files
- `path/to/file.ts:123` - [Purpose]
- `path/to/other.ts:45` - [Purpose]

### Important Details
- Error handling: [Approach with file references]
- Edge cases: [How handled]
- Security: [Considerations if applicable]

Code Location Template

## Location: [Functionality]

### Main Implementation
`path/to/file.ts:45-120` - [Purpose]

### Related Files
- `path/component.tsx` - UI layer
- `path/service.ts` - Business logic
- `path/api.ts` - API integration

### Entry Points
1. [How users trigger this]
2. [System-initiated triggers]

Performance Analysis Template

## Performance Analysis: [Feature]

### Symptoms
- Slow when: [Condition]
- Observed: [X] seconds
- Expected: [Y] seconds

### Root Cause
[What's causing it with file:line evidence]

### Fix Options
**Option A: [Name]**
- Change: [What to do]
- Impact: [Expected improvement]
- Effort: [Time estimate]

**Recommendation:** [Which option and why]

Architecture Mapping Template

## Architecture: [System/Feature]

### Overview
[High-level description]

### Component Breakdown
**[Layer/Module Name]:**
- Responsibility: [What it does]
- Key files: [File paths]
- Dependencies: [What it needs]

### Data Flow
[Step-by-step or diagram]

### Integration Points
- [External services]
- [Related features]

Investigation Workflow

  1. Clarify the question — What are you trying to understand?
  2. Read project docs — Start with overview, feature specs, architecture
  3. Choose investigation type — Flow, location, performance, or architecture
  4. Search strategically — Use direct tools or delegate to agents
  5. Document with file references — Use file:line format for all findings
  6. Offer next steps — Deeper investigation, documentation, or implementation

Key Principles

  • File references matter — Always cite file:line for evidence
  • Evidence-based — Quote actual code, don't guess
  • Multi-domain issues need parallel agents — Frontend + backend require separate investigators
  • Start simple — Use direct grep/read before delegating
  • Consolidate findings — Synthesize parallel agent results into coherent explanation

More by CaptainCrouton89

View all →

reviewing-code

CaptainCrouton89

Systematically evaluate code changes for security, correctness, performance, and spec alignment. Use when reviewing PRs, assessing code quality, or verifying implementation against requirements.

899

railway-cli-management

CaptainCrouton89

Deploy, manage services, view logs, and configure Railway infrastructure. Use when deploying to Railway, managing environment variables, viewing deployment logs, scaling services, or managing volumes.

1173

executing-work-in-parallel

CaptainCrouton89

Coordinate concurrent task execution through agent delegation. Plan independent work, manage dependencies, and execute multiple agents simultaneously. Use when handling multiple unrelated tasks, research investigations, or layer-based implementations that can run concurrently.

00

gathering-requirements

CaptainCrouton89

Systematically clarify user needs, preferences, and constraints before planning or implementation. Classifies work type, investigates existing systems, discovers edge cases and integration points, resolves assumptions, and creates detailed specifications. Use when building features, enhancements, or integrations where requirements need clarification.

00

fixing-bugs-systematically

CaptainCrouton89

Diagnose and fix bugs through systematic investigation, root cause analysis, and targeted validation. Use when something is broken, errors occur, performance degrades, or unexpected behavior manifests.

00

writing-like-user

CaptainCrouton89

Emulate the user's personal writing voice and style patterns. Use when the user asks to write content in their voice, draft documents, compose messages, or requests "write this like me" or "in my style."

770

You might also like

flutter-development

aj-geddes

Build beautiful cross-platform mobile apps with Flutter and Dart. Covers widgets, state management with Provider/BLoC, navigation, API integration, and material design.

245776

drawio-diagrams-enhanced

jgtolentino

Create professional draw.io (diagrams.net) diagrams in XML format (.drawio files) with integrated PMP/PMBOK methodologies, extensive visual asset libraries, and industry-standard professional templates. Use this skill when users ask to create flowcharts, swimlane diagrams, cross-functional flowcharts, org charts, network diagrams, UML diagrams, BPMN, project management diagrams (WBS, Gantt, PERT, RACI), risk matrices, stakeholder maps, or any other visual diagram in draw.io format. This skill includes access to custom shape libraries for icons, clipart, and professional symbols.

188408

godot

bfollington

This skill should be used when working on Godot Engine projects. It provides specialized knowledge of Godot's file formats (.gd, .tscn, .tres), architecture patterns (component-based, signal-driven, resource-based), common pitfalls, validation tools, code templates, and CLI workflows. The `godot` command is available for running the game, validating scripts, importing resources, and exporting builds. Use this skill for tasks involving Godot game development, debugging scene/resource files, implementing game systems, or creating new Godot components.

172268

nano-banana-pro

garg-aayush

Generate and edit images using Google's Nano Banana Pro (Gemini 3 Pro Image) API. Use when the user asks to generate, create, edit, modify, change, alter, or update images. Also use when user references an existing image file and asks to modify it in any way (e.g., "modify this image", "change the background", "replace X with Y"). Supports both text-to-image generation and image-to-image editing with configurable resolution (1K default, 2K, or 4K for high resolution). DO NOT read the image file first - use this skill directly with the --input-image parameter.

199226

ui-ux-pro-max

nextlevelbuilder

"UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 8 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient."

156191

rust-coding-skill

UtakataKyosui

Guides Claude in writing idiomatic, efficient, well-structured Rust code using proper data modeling, traits, impl organization, macros, and build-speed best practices.

157171

Stay ahead of the MCP ecosystem

Get weekly updates on new skills and servers.