Back to skills
SKILL.md
1564 Code Analysis 38b571c8
ASecurityUse graceful degradation for code search and structural analysis.
- 9 stars
- 0 votes
- 0 copies
- 0 views
- Added October 11, 2026
Security analysis
100/100npx -y skills add tools-only/X-Skills --skill 1564-code-analysis_38b571c8 --agent claude-codeAre you the author of 1564 Code Analysis 38b571c8?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/tools-only-1564-code-analysis-38b571c8)# Code Analysis Tools
Use graceful degradation for code search and structural analysis.
## Tool Priority
1. **ast-grep** (`sg`) - Structural pattern-based search
2. **ripgrep** (`rg`) - Fast context-aware text search
3. **grep** - Standard text search (always available)
## Detection
Check tool availability before use:
```bash
# Check for ast-grep
if command -v sg >/dev/null 2>&1; then
# Use ast-grep for structural search
elif command -v rg >/dev/null 2>&1; then
# Fall back to ripgrep
else
# Use standard grep as final fallback
fi
```
## Usage Examples
**Finding function definitions:**
```bash
# ast-grep (best - structural)
sg -p 'function $NAME($$$) { $$$ }'
# ripgrep (fallback - fast text)
rg '^function\s+\w+\(' --type-add 'source:*.[extension]' -t source
# grep (last resort - basic)
grep -r '^function ' --include="*.[extension]"
```
**Finding imports/requires:**
```bash
# ast-grep
sg -p 'import { $$$ } from "$MODULE"'
# ripgrep
rg '^import .* from' --type-add 'source:*.[extension]' -t source
# grep
grep -r '^import ' --include="*.[extension]"
```
**Finding class/component definitions:**
```bash
# ast-grep
sg -p 'class $NAME { $$$ }'
# ripgrep
rg '^(class|export class)\s+\w+' --type-add 'source:*.[extension]' -t source
# grep
grep -r '^class ' --include="*.[extension]"
```
## Search Scope
**Best practices:**
- Limit to source file extensions relevant to project
- Exclude directories: `node_modules`, `vendor`, `dist`, `build`, `.git`
- Focus on source directories: `src`, `lib`, `app`
- Use file type filters when available
**Performance tips:**
- Use specific patterns over broad searches
- Limit directory depth with `--max-depth` (ripgrep/grep)
- Cache results for repeated queries
## Fallback Notice
If ast-grep unavailable, display once per session:
```
⚠️ ast-grep not detected. Install for more precise structural code analysis.
https://ast-grep.github.io/guide/quick-start.html
```
## When to Use
- Finding usage patterns across codebase
- Identifying code structure and organization
- Locating function/class/component definitions
- Analyzing import/dependency patterns
- Refactoring impact analysis
- Code navigation in unfamiliar codebases
Attribution
Comments
Loading comments…
Newsletter
Get the weekly list of safe new skills, and the ones we pulled.