关于 filesystem
filesystem 是为 Claude Code 内置工具提供文件系统操作指引的技能,面向需要读取、修改和查找文件的工作。它涵盖文件发现、内容搜索、编辑验证及目录操作流程。
主要功能
- 01读取单个或多个文件
- 02按模式查找文件
- 03搜索文件内容
- 04创建和修改文件
- 05导航与管理目录
- 06编辑前读取并验证修改
适用场景
- 01批量读取项目文件
- 02查找特定类型或名称的文件
- 03在代码中搜索函数或文本
- 04安全地修改文件并检查结果
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ oimiragieo/ agent-studio --skill filesystem安装后在 Claude Code 中输入/filesystem确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
commands/filesystem.mdhooks/post-execute.cjspre-execute.cjsreferences/research-requirements.mdrules/filesystem.mdschemas/input.schema.jsonoutput.schema.jsonscripts/main.cjstemplates/implementation-template.md详细介绍
文件系统技能
文件系统技能 - 使用 Claude Code 内置工具执行文件系统操作的指南。高效地读取、写入、搜索和管理文件。 - 读取单个或多个文件 - 创建或修改文件 - 按模式搜索文件 - 搜索文件内容 - 浏览目录Claude Code 内置工具
读取文件
Read 工具:读取文件内容
Read file_path="/path/to/file.txt"
选项:
offset:起始行(用于大型文件)limit:读取的行数
查找文件
Glob 工具:按模式查找文件
Glob pattern="**/*.ts"
常见模式:
**/*.ts- 所有 TypeScript 文件src/**/*.tsx- src 中的 React 组件**/test*.js- 任意位置的测试文件
搜索内容
主要搜索方式:使用 pnpm search:code "query" 或 Skill({ skill: 'ripgrep' }) 搜索内容。内置 Grep 工具仅作为备用方案。
Grep 工具:搜索文件内容(仅作为备用方案——优先使用 pnpm search:code 或 ripgrep 技能)
Grep pattern="function myFunc" path="/src"
选项:
output_mode:"content"、"files_with_matches" 或 "count"-A、-B、-C:上下文行数
写入文件
Write 工具:创建或覆盖文件
Write file_path="/path/to/file.txt" content="..."
Edit 工具:修改现有文件
Edit file_path="/path/to/file.txt" old_string="..." new_string="..."
目录操作
Bash 工具:用于目录操作
# List directory
ls -la /path/to/dir
# Create directory
mkdir -p /path/to/new/dir
# Move/rename
mv /old/path /new/path
</execution_process>
<best_practices>
常见工作流
读取多个文件
# Read files in parallel (multiple Read calls in one message)
Read file_path="/src/app.ts"
Read file_path="/src/config.ts"
Read file_path="/src/utils.ts"
搜索并读取
# 1. Find files
Glob pattern="**/*.config.ts"
# 2. Read matching files
Read file_path="/path/from/glob/result"
查找并替换
# 1. Search for pattern
Grep pattern="oldFunction" path="/src"
# 2. Edit each file
Edit file_path="/src/file.ts" old_string="oldFunction" new_string="newFunction"
最佳实践
- 编辑前先读取:编辑文件前务必先读取
- 优先使用 Glob 而非 Bash:查找文件时优先使用 Glob,而非
find - 搜索工具优先级:首先使用
pnpm search:code或Skill({ skill: 'ripgrep' });只有在这些方式不可用时,才使用 Grep 工具,而不是原始 bash grep - 并行读取:在一条消息中读取多个文件以提高速度
- 验证更改:编辑后读取文件以验证更改
</best_practices>
**查找并读取所有 TypeScript 文件**:Glob pattern="src/**/*.ts"
# Then read the results
Read file_path="/src/app.ts"
</usage_example>
<usage_example> 搜索函数并编辑它:
Grep pattern="export function oldName" path="/src"
# Found in /src/utils.ts:23
Edit file_path="/src/utils.ts" old_string="export function oldName" new_string="export function newName"
</usage_example>
规则
- 编辑前务必先读取文件
- 使用内置工具(Read、Glob、Grep),而非对应的 bash 命令
- 编辑后验证更改
记忆协议(强制)
开始前:
cat .claude/context/memory/learnings.md
完成后:
- 新模式 ->
.claude/context/memory/learnings.md - 发现问题 ->
.claude/context/memory/issues.md - 做出决策 ->
.claude/context/memory/decisions.md
假设任务可能中断:你的上下文可能会重置。如果没有记录在记忆中,就等于没有发生。
评论
支持 Markdown