Analyze large codebases using Gemini's 1M token context window through the gemini-code-analyzer subagent. This skill handles pattern detection, code quality analysis, architecture understanding, and comprehensive codebase exploration by spawning a specialized subagent that wraps gemini-cli.
/plugin marketplace add joel611/claude-plugins/plugin install gemini-research@joel-pluginsThis skill inherits all available tools. When active, it can use any tool Claude has access to.
Analyze large codebases using Gemini's 1M token context window through the gemini-code-analyzer subagent. This skill handles pattern detection, code quality analysis, architecture understanding, and comprehensive codebase exploration by spawning a specialized subagent that wraps gemini-cli.
Use this skill when you need to:
Do NOT use this skill when:
Before using this skill:
npm install -g @anthropic/gemini-cliTo verify gemini-cli is installed:
gemini --version
Identify what type of analysis is needed:
Collect relevant information about:
Use the Task tool to spawn the gemini-code-analyzer subagent with a detailed prompt.
Template:
Use the Task tool with:
- subagent_type: "gemini-code-analyzer"
- description: "[Brief 3-5 word description]"
- prompt: "[Detailed analysis request with context]"
Your prompt should include:
The subagent needs detailed context to construct effective gemini-cli commands. Include:
Codebase Information:
Analysis Specifics:
Example Prompt to Subagent:
I need to analyze the React codebase in /Users/joel/my-project for hook usage patterns.
Context:
- This is a Next.js 14 application using the App Router
- Located in: /Users/joel/my-project
- Focus on the app/ and components/ directories
- We're particularly interested in custom hooks
Task:
Analyze all React hooks usage in this codebase. For each hook found:
1. List the hook type (useState, useEffect, custom hooks, etc.)
2. Show where it's used (file paths and approximate line numbers)
3. Identify any custom hooks and their purpose
4. Note any potential issues (missing dependencies, excessive re-renders)
Run gemini-cli with appropriate flags and return the raw output.
Once the subagent returns gemini-cli output:
If the initial analysis needs refinement:
User Request: "Find all React hooks in the codebase and identify any issues"
Step 1 - Identify: Pattern Detection analysis
Step 2 - Gather Context:
Step 3 - Spawn Subagent:
Task tool with subagent_type: "gemini-code-analyzer"
Prompt:
"Analyze the React codebase at /Users/joel/my-app for hooks usage patterns.
Context:
- Next.js 14 application with App Router
- TypeScript-based React components
- Focus on all .tsx files in app/ and components/ directories
Analysis Request:
Find all React hooks usage in this codebase and analyze them:
1. Built-in hooks (useState, useEffect, useContext, etc.):
- Count usage of each hook type
- Identify the most commonly used hooks
2. Custom hooks:
- List all custom hooks defined
- Show where each custom hook is used
- Describe each custom hook's purpose
3. Potential issues:
- Missing dependencies in useEffect
- Hooks called conditionally or in loops
- Excessive re-renders from state updates
- Complex hook chains that could be simplified
Output format:
Provide a structured report with file paths and approximate line numbers for each finding.
Run: gemini --all-files --yolo -p with the above analysis prompt
Return the raw gemini output."
Step 5 - Process Results:
Based on gemini's analysis, here's what I found:
## Hooks Usage Summary
### Built-in Hooks
- useState: 47 instances across 23 components
- useEffect: 31 instances across 18 components
- useContext: 12 instances (AuthContext, ThemeContext)
- useCallback: 8 instances
- useMemo: 5 instances
### Custom Hooks (4 found)
1. `useAuth` (hooks/useAuth.ts:12) - Used in 8 components
2. `useLocalStorage` (hooks/useLocalStorage.ts:8) - Used in 3 components
3. `useDebounce` (hooks/useDebounce.ts:5) - Used in 2 components
4. `useFetch` (hooks/useFetch.ts:15) - Used in 6 components
### Issues Identified
⚠️ Missing dependencies in components/Dashboard.tsx:45
⚠️ Conditional hook call in components/UserProfile.tsx:78
⚠️ Potential re-render issue in components/ProductList.tsx:92
Next steps:
1. Fix the missing dependencies in Dashboard component
2. Refactor conditional hook usage in UserProfile
3. Consider memoization in ProductList to reduce re-renders
User Request: "I need to understand the authentication flow in this application"
Spawn Subagent:
Task tool with subagent_type: "gemini-code-analyzer"
Prompt:
"Analyze the authentication flow in the codebase at /Users/joel/my-app.
Context:
- Next.js application with API routes
- Using JWT for authentication
- Has both client and server-side auth checks
Analysis Request:
Trace the complete authentication flow through this application:
1. Authentication Entry Points:
- Where does login/signup happen? (UI components, API routes)
- What authentication methods are supported?
2. Token Management:
- How are JWT tokens created?
- Where are tokens stored? (cookies, localStorage, etc.)
- How are tokens validated?
3. Protected Routes:
- Which routes require authentication?
- How are auth checks implemented (middleware, HOCs, etc.)?
- Where are unauthorized users redirected?
4. Session Management:
- How are sessions maintained?
- What's the token refresh mechanism?
- How does logout work?
5. Data Flow:
- Map the complete flow from login button click to authenticated state
- Show all components and functions involved
- Include file paths for each step
Run: gemini --all-files --yolo -p with the above prompt
Return the raw output."
User Request: "Check the codebase for security vulnerabilities"
Spawn Subagent:
Task tool with subagent_type: "gemini-code-analyzer"
Prompt:
"Perform a security audit on the codebase at /Users/joel/my-app.
Context:
- Node.js/Express API backend
- React frontend
- PostgreSQL database
- Handles user data and payments
Security Analysis:
Audit the codebase for common security vulnerabilities:
1. Injection Vulnerabilities:
- SQL injection risks (raw queries, dynamic SQL)
- NoSQL injection risks
- Command injection possibilities
2. XSS (Cross-Site Scripting):
- Unsanitized user input rendering
- Dangerous use of dangerouslySetInnerHTML
- Unsafe DOM manipulation
3. Authentication & Authorization:
- Weak password policies
- Insecure token storage
- Missing authorization checks
- Session management issues
4. Sensitive Data Exposure:
- Hardcoded secrets or API keys
- Logging sensitive information
- Unencrypted data transmission
5. API Security:
- Missing rate limiting
- CORS misconfigurations
- Unvalidated input
- Missing CSRF protection
For each finding:
- Severity level (Critical, High, Medium, Low)
- File path and location
- Description of the vulnerability
- Potential impact
- Recommended fix
Run: gemini --all-files --yolo -p with security analysis
Return raw output."
User Request: "Find performance issues in the React application"
Spawn Subagent:
Task tool with subagent_type: "gemini-code-analyzer"
Prompt:
"Analyze performance bottlenecks in the React application at /Users/joel/my-app.
Context:
- React 18 with Next.js 14
- Large component tree (~100 components)
- User reports slow rendering
Performance Analysis:
Identify performance bottlenecks in this application:
1. Re-render Issues:
- Components that re-render unnecessarily
- Missing React.memo optimizations
- Inefficient state updates
- Context API performance issues
2. Bundle Size:
- Large imported libraries
- Unused dependencies
- Missing code splitting
- Opportunities for lazy loading
3. Data Fetching:
- Sequential API calls that could be parallel
- Missing caching strategies
- Over-fetching data
- N+1 query patterns
4. Expensive Operations:
- Complex calculations in render
- Missing useMemo/useCallback
- Large list rendering without virtualization
- Unoptimized images
5. Next.js Specific:
- Improper use of Server/Client Components
- Missing static generation opportunities
- Inefficient data fetching patterns
For each issue found:
- File path and location
- Description of the problem
- Performance impact (estimated)
- Recommended optimization
- Code example if applicable
Run: gemini --all-files --yolo -p with performance analysis
Return raw output."
Problem: gemini-cli is not installed or not in PATH
Solutions:
npm install -g @anthropic/gemini-cligemini --versionProblem: Gemini returns generic or unfocused results
Solutions:
Problem: Gemini's analysis doesn't include file locations
Solutions:
Problem: gemini-cli takes a very long time to respond
Solutions:
Problem: Results don't match what was requested
Solutions:
Problem: Request requires multiple types of analysis
Solutions:
For complex analysis requiring multiple phases:
Create specialized analysis workflows:
Security Audit Workflow:
Performance Optimization Workflow:
Refactoring Planning Workflow:
The code-analyzer skill uses the gemini-code-analyzer agent, which:
For more information:
plugins/analysis/gemini-research/agents/code-analyzer.md