file-analysis
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseFile 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.
- 架构审查前,用于了解模块边界和文件组织结构。
- 探索陌生代码库时,在进行修改前梳理结构。
- 作为重构或迁移工作范围估算的输入依据。
When NOT To Use
不适用场景
- General code exploration - use the Explore agent
- Searching for specific patterns - use Grep directly
- 通用代码探索——请使用Explore Agent
- 搜索特定模式——请直接使用Grep
Required TodoWrite Items
必备TodoWrite任务项
file-analysis:root-identifiedfile-analysis:structure-mappedfile-analysis:patterns-detectedfile-analysis:hotspots-noted
Mark each item as complete as you finish the corresponding step.
file-analysis:root-identifiedfile-analysis:structure-mappedfile-analysis:patterns-detectedfile-analysis:hotspots-noted
完成对应步骤后,标记每个任务项为已完成。
Step 1: Identify Root (file-analysis:root-identified
)
file-analysis:root-identified步骤1:确定根目录(file-analysis:root-identified
)
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, etc.).pyproject.toml
- 使用命令确认分析的根目录。
pwd - 记录任何单体仓库边界、工作区根目录或子项目路径。
- 从清单文件(、
package.json、Cargo.toml等)中识别项目类型(语言、框架)。pyproject.toml
Step 2: Map Structure (file-analysis:structure-mapped
)
file-analysis:structure-mapped步骤2:梳理结构(file-analysis:structure-mapped
)
file-analysis:structure-mapped- Run or
tree -L 2 -dto capture the top-level directory layout.find . -type d -maxdepth 2 - Identify standard directories: ,
src/,lib/,tests/,docs/,scripts/.configs/ - Note any non-standard organization patterns that may affect downstream analysis.
- 运行或
tree -L 2 -d命令捕获顶级目录布局。find . -type d -maxdepth 2 - 识别标准目录:、
src/、lib/、tests/、docs/、scripts/。configs/ - 记录任何可能影响后续分析的非标准组织模式。
Step 3: Detect Patterns (file-analysis:patterns-detected
)
file-analysis:patterns-detected步骤3:检测模式(file-analysis:patterns-detected
)
file-analysis:patterns-detected- Use to count files by extension.
find . -name "*.ext" | wc -l - Identify dominant languages and their file distributions.
- Note configuration files, generated files, and vendored dependencies.
- Run to sample file sizes.
wc -l $(find . -name "*.py" -o -name "*.rs" | head -20)
- 使用命令按文件扩展名统计文件数量。
find . -name "*.ext" | wc -l - 识别主导语言及其文件分布情况。
- 记录配置文件、生成文件和第三方依赖文件。
- 运行命令抽样查看文件大小。
wc -l $(find . -name "*.py" -o -name "*.rs" | head -20)
Step 4: Note Hotspots (file-analysis:hotspots-noted
)
file-analysis:hotspots-noted步骤4:标记热点(file-analysis:hotspots-noted
)
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.
- 识别大文件(潜在的“上帝对象”):。
find . -type f -exec wc -l {} + | sort -rn | head -10 - 标记可能表明复杂度高的深层嵌套目录。
- 记录具有不寻常命名规范或放置位置的文件。
Exit Criteria
退出标准
- items are completed with concrete observations.
TodoWrite - Downstream workflows (architecture review, refactoring) have structural context.
- File counts, directory layout, and hotspots are documented for reference.
- TodoWrite任务项已完成并记录具体观察结果。
- 后续工作流(架构审查、重构)已获取结构上下文。
- 文件数量、目录布局和热点已记录归档,以供参考。
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 flag
--verbose命令未找到
确保所有依赖项已安装并在PATH环境变量中
权限错误
检查文件权限并使用适当权限运行命令
异常行为
使用标志启用详细日志
--verbose