dev_inspect
Inspect a file for pattern analysis. Finds similar code and compares patterns like error handling, type coverage, imports, and testing.
Usage
dev_inspect(query, format?, limit?, threshold?)Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
query | string | required | File path to inspect |
format | "compact" | "verbose" | "compact" | Output format |
limit | number | 10 | Maximum similar files to analyze |
threshold | number | 0.7 | Similarity threshold (0-1) |
What It Does
dev_inspect performs comprehensive file analysis in two steps:
- Finds similar files - Uses semantic search to find code with similar structure/purpose
- Analyzes patterns - Compares error handling, type coverage, imports, testing, and file size
This helps you understand how your file compares to similar code in the repository.
Examples
Basic Inspection
āUse dev_inspect with query āsrc/auth/middleware.tsāā
## File Inspection: src/auth/middleware.ts
### Similar Files (5 analyzed)
1. `src/auth/session.ts` (78%)
2. `src/middleware/logger.ts` (72%)
3. `src/api/auth-handler.ts` (68%)
### Pattern Analysis
**Import Style:** Your file uses `esm`, matching 100% of similar files.
**Error Handling:** Your file uses `throw`, but 60% of similar files use `result`.
**Type Coverage:** Your file has `full` type coverage, matching 80% of similar files.
**Testing:** No test file found. 40% of similar files have tests.
**Size:** 234 lines (smaller than average of 312 lines)Verbose Output
āUse dev_inspect with query āpackages/core/src/indexer/index.tsā, format āverboseāā
Returns detailed pattern distribution and statistics for each pattern category.
High Similarity Only
āUse dev_inspect with query āsrc/utils/date.tsā, threshold 0.9ā
Only analyzes very similar files (90%+ match).
Pattern Categories
dev_inspect analyzes 5 key patterns:
| Pattern | What It Checks |
|---|---|
| Import Style | esm, cjs, mixed, or unknown |
| Error Handling | throw, result, callback, or unknown |
| Type Coverage | full, partial, or none (TypeScript only) |
| Testing | Whether a co-located test file exists |
| File Size | Line count vs. similar files |
Output Formats
Compact (Default)
Shows pattern summary with actionable insights:
**Error Handling:** Your file uses `throw`, but 60% of similar files use `result`.Highlights differences from similar files to guide improvements.
Verbose
Shows full pattern distribution:
#### Error Handling
- **Your File:** `throw`
- **Common Style:** `result` (60% of similar files)
- **Distribution:**
- result: 3 files (60%)
- throw: 2 files (40%)Use Cases
| Use Case | Description |
|---|---|
| Code Review | Check if your code follows project patterns |
| Refactoring | Understand pattern usage before making changes |
| Consistency | Ensure new code matches similar implementations |
| Learning | See how patterns are used across the codebase |
Workflow
Typical usage pattern:
- Search for concepts:
dev_search { query: "authentication middleware" } - Inspect what you found:
dev_inspect { query: "src/auth/middleware.ts" } - Analyze dependencies:
dev_refs { name: "authMiddleware" }
Tips
Always provide a file path. Unlike
dev_search,dev_inspectrequires a specific file to analyze.
Extension filtering. Only compares files with the same extension (e.g.,
.tswith.ts).
Use after search.
dev_inspectis most valuable after finding relevant files withdev_search.
Pattern-driven insights. Focus on patterns where your file differs from similar code.
Performance
dev_inspect is optimized for speed:
- Batch scanning (5-10x faster than individual scans)
- Semantic similarity matching (not just path-based)
- Extension-based filtering for relevant comparisons
Typical analysis time: 500-1000ms for 5 similar files.
Migration from dev_explore
If you previously used dev_explore:
dev_explore { action: "similar", query: "file.ts" }ādev_inspect { query: "file.ts" }dev_explore { action: "validate", query: "file.ts" }ādev_inspect { query: "file.ts" }(now does both!)dev_explore { action: "pattern" }ā Usedev_searchinsteaddev_explore { action: "relationships" }ā Usedev_refsinstead
Key change: dev_inspect no longer requires an action parameter. It automatically finds similar files AND performs pattern analysis in one call.