Hunt down every TODO comment, deprecated function call, or security anti-pattern across your entire codebase. Get intelligent context analysis that shows you exactly where problems lurk and what needs fixing.

Quick Start

Jump straight in with these powerful pattern searches:

Find All TODO Comments
Find all TODO comments in my project at C:/my-project/src
Hunt for Security Issues
Search for eval( and innerHTML usage in C:/project - need to check security
Track Down Deprecated APIs
Find componentWillMount and findDOMNode usage in my React project C:/react-app

Smart Pattern Matching

This isn't just grep - you get intelligent context analysis, categorization, and actionable remediation suggestions for every match.

What It Does

Think of this as a super-powered search that understands your code. find_pattern_usage searches for user-defined patterns (text or regex) across your entire project and provides contextual analysis of each match that goes far beyond simple string matching.

What makes this special:

  • Intelligent Context - Shows surrounding code to understand usage patterns
  • Pattern Categorization - Groups matches by type and severity
  • Risk Assessment - Identifies which patterns are problematic vs. benign
  • Remediation Guidance - Specific suggestions for fixing issues
  • Usage Statistics - Shows frequency and distribution across your codebase

Perfect for technical debt hunting, security audits, migration planning, and code quality improvements. You'll discover patterns you didn't even know existed in your codebase.

Parameters

Configure your pattern search to find exactly what you're looking for:

Parameter Type Required Default Description
patterns array Yes -

Patterns to search for - text or regex supported

Example: ["TODO", "FIXME", "console\.log"]
projectPath string Yes* -

Path to project root directory to search

Example: "C:/my-project/src"
filePath string Yes* -

Single file to search (alternative to projectPath)

Perfect for focused searches
files array Yes* -

Specific files to analyze (alternative to projectPath)

When you know exactly which files to check
includeContext number No 3

Number of context lines to include (0-10)

More context = better analysis but longer results
analysisType string No "comprehensive"

Focus: "patterns", "security", "comprehensive"

"security" mode provides extra risk analysis
maxDepth number No 3

Maximum directory depth to search (1-5)

Higher values search deeper but take longer

*One of projectPath, filePath, or files is required

Real-World Pattern Hunts

Here's how to track down common issues and patterns:

🔍 Technical Debt Discovery

Find All Technical Debt Markers
houtini-lm:find_pattern_usage with:
- patterns: ["TODO", "FIXME", "HACK", "XXX", "BUG"]
- projectPath: "C:/my-project/src"
- includeContext: 5
- analysisType: "comprehensive"

🛡️ Security Anti-Pattern Detection

Hunt for Security Issues
houtini-lm:find_pattern_usage with:
- patterns: ["eval\\(", "innerHTML", "dangerouslySetInnerHTML", "document\\.write"]
- projectPath: "C:/web-app"
- analysisType: "security"
- includeContext: 7

📱 React Migration Patterns

Find Deprecated React Patterns
houtini-lm:find_pattern_usage with:
- patterns: ["componentWillMount", "componentWillReceiveProps", "findDOMNode", "ReactDOM\\.findDOMNode"]
- projectPath: "C:/react-app/src"
- includeContext: 4
- maxDepth: 4

🐛 Debug Code Detection

Find Leftover Debug Code
houtini-lm:find_pattern_usage with:
- patterns: ["console\\.log", "console\\.debug", "debugger;", "alert\\(", "print_r\\("]
- projectPath: "C:/project/src"
- includeContext: 2

🔧 WordPress Security Patterns

WordPress Security Issues
houtini-lm:find_pattern_usage with:
- patterns: ["\\$_GET", "\\$_POST", "\\$_REQUEST", "mysql_query", "stripslashes"]
- projectPath: "C:/wp-plugin"
- analysisType: "security"
- includeContext: 6

📦 Dependency Usage Analysis

Track Library Usage
houtini-lm:find_pattern_usage with:
- patterns: ["lodash", "moment", "jquery", "axios"]
- files: ["C:/project/src/utils.js", "C:/project/src/api.js"]
- includeContext: 3

What You Get Back

This function delivers actionable intelligence about every pattern match:

📍 Pattern Matches with Context

  • Exact locations - File paths with line numbers
  • Contextual code - Surrounding lines to understand usage
  • Match highlighting - Clear identification of found patterns
  • Function/class context - Which function or class contains the match

🎯 Pattern Categorization

  • Risk levels - High, medium, low risk classification
  • Pattern types - Technical debt, security issue, deprecated code
  • Severity assessment - Which patterns need immediate attention
  • Usage frequency - How often each pattern appears

📊 Usage Statistics

  • Total matches - Overall count per pattern
  • File distribution - Which files have the most matches
  • Directory analysis - Patterns concentrated in specific areas
  • Trend identification - Recent vs. legacy pattern usage

🔧 Remediation Suggestions

  • Specific fixes - How to address each pattern type
  • Migration guides - Moving from deprecated to modern patterns
  • Security recommendations - Safer alternatives for risky patterns
  • Priority ranking - Which issues to fix first

🎨 Priority Matrix

  • Critical - Security issues, production bugs
  • High Priority - Performance issues, deprecated APIs
  • Medium Priority - Code quality, maintainability
  • Low Priority - Style issues, nice-to-haves

Actionable Intelligence

Every result comes with context, impact assessment, and clear next steps. You'll know exactly what needs fixing and why it matters.

Perfect Use Cases

Here's when this function becomes your code detective:

🕵️ Technical Debt Archaeology

Find all those forgotten TODO comments, HACK fixes, and FIXME notes scattered throughout your codebase. Perfect before code reviews or major releases.

🛡️ Security Audit Preparation

Hunt down potential security vulnerabilities like eval() usage, innerHTML assignments, or unsafe SQL patterns before security reviews.

📱 Framework Migration Planning

Identify all usage of deprecated APIs when upgrading React, Angular, or any other framework. Get a complete migration checklist automatically.

🚀 Pre-Production Cleanup

Find leftover console.log statements, debug code, alert() calls, or test data before deploying to production.

📚 Code Quality Improvements

Identify anti-patterns, outdated approaches, or inconsistent coding styles across your team's codebase.

🔄 Refactoring Preparation

Before major refactoring, understand how specific patterns are used throughout your codebase to plan breaking changes safely.

📖 Documentation Generation

Find all usage of specific APIs or patterns to generate migration guides or usage documentation.

🎯 Code Review Assistance

Automatically flag common issues before peer review, making code reviews more efficient and thorough.

Best Practices

Get the most insightful pattern analysis with these expert tips:

🎯 Smart Pattern Selection

Choose patterns that provide actionable insights:

  • Be specific - "componentWillMount" better than "component"
  • Use regex wisely - "console\\.log" catches console.log but not "console_log"
  • Group related patterns - Search for all debug patterns together
  • Consider context - Some patterns are fine in test files but not production

📊 Context Configuration

Balance detail with readability:

  • 3-5 context lines - Perfect for most searches
  • 7-10 for security - More context helps assess risk
  • 1-2 for simple patterns - TODO comments need less context
  • 0 for counts only - When you just need statistics

🔍 Analysis Type Selection

  • "security" - When hunting for vulnerabilities
  • "patterns" - For general code pattern analysis
  • "comprehensive" - When you want deep insights

🎨 Effective Pattern Categories

Security Patterns to Hunt

  • eval\(, innerHTML, document\.write
  • \$_GET, \$_POST (WordPress/PHP)
  • dangerouslySetInnerHTML (React)

Technical Debt Markers

  • TODO, FIXME, HACK, XXX
  • @deprecated, @todo
  • temporary, quick fix

Debug Code Patterns

  • console\.(log|debug|warn)
  • debugger;, alert\(
  • print_r\(, var_dump\( (PHP)

⚡ Performance Tips

  • Start focused - Single directory before full project
  • Limit depth - Use maxDepth 3-4 for large projects
  • Batch similar patterns - Search related patterns together
  • Use specific files - When you know where to look

Pro Tip

Regex patterns are powerful but can be slow on large codebases. Test complex patterns on small directories first, then expand your search scope.

Troubleshooting

Solve common pattern hunting challenges:

No matches found when I know patterns exist

Your patterns aren't matching what you expect to find.

  • Check regex escaping - use console\\.log not console.log
  • Verify file extensions are being searched (maxDepth might be too shallow)
  • Try exact string matches first, then add regex complexity
  • Use broader projectPath to ensure you're searching the right directories
Too many irrelevant matches

Getting lots of false positives or matches in files you don't care about.

  • Use more specific patterns - componentWillMount not component
  • Reduce includeContext to focus on exact matches
  • Use the files parameter to target specific files instead of projectPath
  • Add word boundaries to regex patterns: \\bconsole\\b
Search takes too long or times out

Pattern search is running slowly or timing out on large codebases.

  • Reduce maxDepth to 2-3 for initial searches
  • Use specific directories instead of entire project root
  • Simplify complex regex patterns - test them individually first
  • Search for fewer patterns per request
Context lines aren't helpful

The surrounding context doesn't provide enough information to understand matches.

  • Increase includeContext to 5-7 for more surrounding code
  • Use analysisType "comprehensive" for better pattern analysis
  • For security patterns, try includeContext 7-10
  • Consider analyzing specific files individually for detailed context
Regex patterns not working as expected

Regular expressions aren't matching patterns correctly.

  • Escape special characters: \. for literal dots
  • Use double backslashes in JSON: "console\\.log"
  • Test regex patterns with simple examples first
  • Remember that patterns are case-sensitive by default
Missing patterns in node_modules or specific directories

Some directories or file types aren't being searched.

  • Check that your projectPath includes the directories you want searched
  • Increase maxDepth if patterns are in deeply nested directories
  • Some directories might be automatically excluded for performance
  • Use specific file paths if you need to search normally excluded areas