analyze-function
Deep line-by-line analysis of a function or method. Explains what each line does, why it's written that way, performance implications, edge cases, and design patterns. Use when user says "analyze-function", "analyze {function}", "deep dive on {function}", or "explain {function} line by line".
Best use case
analyze-function is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Deep line-by-line analysis of a function or method. Explains what each line does, why it's written that way, performance implications, edge cases, and design patterns. Use when user says "analyze-function", "analyze {function}", "deep dive on {function}", or "explain {function} line by line".
Teams using analyze-function should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/analyze-function/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How analyze-function Compares
| Feature / Agent | analyze-function | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Deep line-by-line analysis of a function or method. Explains what each line does, why it's written that way, performance implications, edge cases, and design patterns. Use when user says "analyze-function", "analyze {function}", "deep dive on {function}", or "explain {function} line by line".
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Analyze Function
Perform a thorough line-by-line analysis of a function, explaining not just what the code does but why it's written this way.
## When to Use
- Understanding unfamiliar or complex code
- Onboarding to a new codebase
- Pre-refactor deep understanding
- Performance investigation
- Code archaeology (understanding legacy code intent)
- Learning from well-written code
## Process
### 1. Parse Request
Extract:
- File path containing the function
- Function/method name to analyze
Formats to recognize:
- `{file}:{function_name}`
- `{function_name} in {file}`
- Just `{function_name}` (search for it)
### 2. Locate the Function
1. Read the file
2. Find the function definition
3. Identify the full scope (including nested functions, closures)
4. Note the line numbers
### 3. Gather Context
Before line-by-line analysis, understand:
- What module/class is this part of?
- What calls this function? (if easily determinable)
- What does this function call?
- Any relevant types, interfaces, or data structures
### 4. Analyze Each Line
Open [ANALYSIS-GUIDE.md](ANALYSIS-GUIDE.md) for the detailed framework.
For every line, consider:
- **What**: Technical explanation of what this line does
- **Why**: Rationale for this approach (not just restating the what)
- **Note**: Performance implications, edge cases, or gotchas (when relevant)
Do not skip "boring" lines. Every line exists for a reason.
### 5. Identify Critical Details
After line-by-line, explicitly list things that might be missed on casual reading:
- Implicit assumptions the code makes
- Non-obvious behavior or side effects
- Hidden dependencies
- Subtle edge cases
- Error conditions that aren't obvious
### 6. Note Design Patterns
If the function uses notable patterns or techniques, name them:
- Design patterns (Factory, Observer, etc.)
- Language idioms
- Performance optimization techniques
- Error handling patterns
### 7. Suggest Improvements (If Any)
Only if genuine concerns exist:
- Potential bugs or edge cases not handled
- Performance issues
- Readability improvements
- Missing error handling
Do not invent issues. If the code is solid, say so.
## Output Format
```markdown
## Function Analysis: {function_name}
**File**: `{path/to/file.ext}`
**Lines**: {start}-{end}
**Language**: {language}
### Context & Purpose
{2-3 sentences: What this function does, where it fits in the system, why it exists}
### Line-by-Line Analysis
**Line {N}**: `{code}`
- **What**: {technical explanation}
- **Why**: {rationale for this approach}
- **Note**: {performance implication, edge case, or gotcha}
**Line {N+1}**: `{code}`
- **What**: {explanation}
- **Why**: {rationale}
{Continue for all lines...}
### Critical Details
Things that might be missed on casual reading:
- {Non-obvious behavior or assumption}
- {Hidden dependency or side effect}
- {Subtle edge case}
### Design Patterns
- **{Pattern name}**: {How it's applied here}
### Potential Improvements
{If any genuine issues exist:}
- {Concern}: {explanation}
{Or if code is solid:}
No significant issues identified. The implementation is {brief positive assessment}.
```
## Guidelines
- **Be thorough**: Every line matters. Don't summarize or skip.
- **Explain why, not just what**: "Initializes counter to 0" is useless. "Starts at 0 because indexes are zero-based and we're tracking position" is useful.
- **Be honest about uncertainty**: If you're not sure why something is done a certain way, say so.
- **Connect to context**: How does this line relate to the function's purpose?
- **Note the non-obvious**: What would trip up someone reading this quickly?Related Skills
analyze-rust-optimizations
This skill performs thorough analysis of Rust libraries to find optimization opportunities. It should be used when reviewing Rust code for performance improvements, memory efficiency, or when profiling indicates bottlenecks. Focuses on runtime performance and memory usage through dynamic profiling tools and static code analysis.
analyze-project-architecture
LLM-based architectural analysis that transforms raw project data into meaningful structure
analyze-pr-performance
Analyze code review pipeline performance for a specific PR. Use when investigating slow PRs, identifying bottlenecks, or debugging performance issues in code reviews.
analyze
Deep analysis and investigation
analyze-m1-module-for-migration
Systematically analyze a Magento 1 module to determine its purpose, usage, and migration requirements for Magento 2. Use when you need to decide whether to migrate a M1 module, find alternatives, or skip it.
analyze-friction
Orchestrate 3-stage friction analysis workflow across conversations. Extracts raw friction, abstracts patterns, and presents for approval. Use when user wants to analyze conversation history for improvement opportunities.
analyze-codebase
Analyze a codebase to generate a comprehensive architecture and structure report. Use when user wants to understand a codebase, explore project structure, or generate analysis.
analyze-code
Deep code analysis using consultant agent. Identifies technical debt, risks, and improvement opportunities.
analyze-code-structure
Examine code organization and identify structural patterns. Use when reviewing module design.
analyze-architecture
Comprehensive brownfield architecture analysis for existing codebases. Discovers structure, identifies patterns, assesses quality, calculates production readiness, and provides actionable recommendations. Use when analyzing existing codebases to understand architecture, assess quality, or prepare for modernization.
acc-analyze-solid-violations
Analyzes PHP codebase for SOLID principle violations. Detects God classes (SRP), type switches (OCP), broken contracts (LSP), fat interfaces (ISP), and concrete dependencies (DIP). Generates actionable reports with severity levels and remediation recommendations.
30-analyze-impact-150
[30] ANALYZE. Understand how changes impact the system — what's the core, what's affected, what depends on what. Use when planning changes, analyzing systems, debugging issues, or anytime you need to see the full picture of cause and effect. Triggers on "what's affected", "impact analysis", "dependencies", "scope mapping", or when you need to understand ripple effects.