name: file-analysis
description: |
Triggers: codebase, file, analysis, structure, exploration
Structured file enumeration and content analysis for understanding codebase
structure before reviews or refactoring.
Triggers: file analysis, codebase structure, directory mapping, hotspot detection,
code exploration, file enumeration, structure mapping, module boundaries
Use when: before architecture reviews to understand file organization, exploring
unfamiliar codebases to map structure, estimating scope for refactoring or migration
DO NOT use when: general code exploration - use the Explore agent.
DO NOT use when: searching for specific patterns - use Grep directly.
Provides structural context for downstream review and refactoring workflows.
category: workspace-ops
tags: [files, structure, analysis, codebase, exploration]
tools: [Bash, Glob, Grep, TodoWrite]
complexity: medium
estimated_tokens: 800
dependencies:
- sanctum:shared
- imbue:evidence-logging
version: 1.3.7
File Analysis
When to Use
- Before architecture reviews to understand module boundaries and file organization.
- When exploring unfamiliar codebases to map structure before making changes.
- As input to scope estimation for refactoring or migration work.
Required TodoWrite Items
file-analysis:root-identified
file-analysis:structure-mapped
file-analysis:patterns-detected
file-analysis:hotspots-noted
Mark each item as complete as you finish the corresponding step.
Step 1: Identify Root (file-analysis:root-identified)
- Confirm the analysis root directory with
pwd.
- Note any monorepo boundaries, workspace roots, or subproject paths.
- Capture the project type (language, framework) from manifest files (
package.json, Cargo.toml, pyproject.toml, etc.).
Step 2: Map Structure (file-analysis:structure-mapped)
- Run
tree -L 2 -d or find . -type d -maxdepth 2 to capture the top-level directory layout.
- Identify standard directories:
src/, lib/, tests/, docs/, scripts/, configs/.
- Note any non-standard organization patterns that may affect downstream analysis.
Step 3: Detect Patterns (file-analysis:patterns-detected)
- Use
find . -name "*.ext" | wc -l to count files by extension.
- Identify dominant languages and their file distributions.
- Note configuration files, generated files, and vendored dependencies.
- Run
wc -l $(find . -name "*.py" -o -name "*.rs" | head -20) to sample file sizes.
Step 4: Note Hotspots (file-analysis:hotspots-noted)
- Identify large files (potential "god objects"):
find . -type f -exec wc -l {} + | sort -rn | head -10.
- Flag deeply nested directories that may indicate complexity.
- Note files with unusual naming conventions or placement.
Exit Criteria
TodoWrite items are completed with concrete observations.
- Downstream workflows (architecture review, refactoring) have structural context.
- File counts, directory layout, and hotspots are documented for reference.
Troubleshooting
Common Issues
Command not found
Ensure all dependencies are installed and in PATH
Permission errors
Check file permissions and run with appropriate privileges
Unexpected behavior
Enable verbose logging with --verbose flag
1---2name: file-analysis3description: - Before architecture reviews to understand module boundaries and file organization.4---5
6---
7name: file-analysis
8description: |
9
10Triggers: codebase, file, analysis, structure, exploration
11 Structured file enumeration and content analysis for understanding codebase
12 structure before reviews or refactoring.
13
14 Triggers: file analysis, codebase structure, directory mapping, hotspot detection,
15 code exploration, file enumeration, structure mapping, module boundaries
16
17 Use when: before architecture reviews to understand file organization, exploring
18 unfamiliar codebases to map structure, estimating scope for refactoring or migration
19
20 DO NOT use when: general code exploration - use the Explore agent.
21 DO NOT use when: searching for specific patterns - use Grep directly.
22
23 Provides structural context for downstream review and refactoring workflows.
24category: workspace-ops
25tags: [files, structure, analysis, codebase, exploration]
26tools: [Bash, Glob, Grep, TodoWrite]
27complexity: medium
28estimated_tokens: 800
29dependencies:
30 - sanctum:shared
31 - imbue:evidence-logging
32version: 1.3.7
33---
34
35# File Analysis
36
37## When to Use
38- Before architecture reviews to understand module boundaries and file organization.
39- When exploring unfamiliar codebases to map structure before making changes.
40- As input to scope estimation for refactoring or migration work.
41
42## Required TodoWrite Items
431. `file-analysis:root-identified`
442. `file-analysis:structure-mapped`
453. `file-analysis:patterns-detected`
464. `file-analysis:hotspots-noted`
47
48Mark each item as complete as you finish the corresponding step.
49
50## Step 1: Identify Root (`file-analysis:root-identified`)
51- Confirm the analysis root directory with `pwd`.
52- Note any monorepo boundaries, workspace roots, or subproject paths.
53- Capture the project type (language, framework) from manifest files (`package.json`, `Cargo.toml`, `pyproject.toml`, etc.).
54
55## Step 2: Map Structure (`file-analysis:structure-mapped`)
56- Run `tree -L 2 -d` or `find . -type d -maxdepth 2` to capture the top-level directory layout.
57- Identify standard directories: `src/`, `lib/`, `tests/`, `docs/`, `scripts/`, `configs/`.
58- Note any non-standard organization patterns that may affect downstream analysis.
59
60## Step 3: Detect Patterns (`file-analysis:patterns-detected`)
61- Use `find . -name "*.ext" | wc -l` to count files by extension.
62- Identify dominant languages and their file distributions.
63- Note configuration files, generated files, and vendored dependencies.
64- Run `wc -l $(find . -name "*.py" -o -name "*.rs" | head -20)` to sample file sizes.
65
66## Step 4: Note Hotspots (`file-analysis:hotspots-noted`)
67- Identify large files (potential "god objects"): `find . -type f -exec wc -l {} + | sort -rn | head -10`.
68- Flag deeply nested directories that may indicate complexity.
69- Note files with unusual naming conventions or placement.
70
71## Exit Criteria
72- `TodoWrite` items are completed with concrete observations.
73- Downstream workflows (architecture review, refactoring) have structural context.
74- File counts, directory layout, and hotspots are documented for reference.
75## Troubleshooting
76
77### Common Issues
78
79**Command not found**
80Ensure all dependencies are installed and in PATH
81
82**Permission errors**
83Check file permissions and run with appropriate privileges
84
85**Unexpected behavior**
86Enable verbose logging with `--verbose` flag