filesystem
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseFilesystem Skill
Filesystem Skill
<identity>
Filesystem Skill - Guidance for file system operations using Claude Code's built-in tools. Read, write, search, and manage files efficiently.
</identity>
<capabilities>
- Reading single or multiple files
- Creating or modifying files
- Searching for files by pattern
- Searching file contents
- Directory navigation
</capabilities>
<instructions>
<execution_process>
<identity>
Filesystem Skill - 指导如何使用Claude Code内置工具进行文件系统操作,高效地读取、写入、搜索和管理文件。
</identity>
<capabilities>
- 读取单个或多个文件
- 创建或修改文件
- 按模式搜索文件
- 搜索文件内容
- 目录导航
</capabilities>
<instructions>
<execution_process>
Claude Code Built-in Tools
Claude Code内置工具
Reading Files
读取文件
Read Tool: Read file contents
Read file_path="/path/to/file.txt"Options:
- : Start line (for large files)
offset - : Number of lines to read
limit
Read工具: 读取文件内容
Read file_path="/path/to/file.txt"选项:
- : 起始行(针对大文件)
offset - : 要读取的行数
limit
Finding Files
查找文件
Glob Tool: Find files by pattern
Glob pattern="**/*.ts"Common patterns:
- - All TypeScript files
**/*.ts - - React components in src
src/**/*.tsx - - Test files anywhere
**/test*.js
Glob工具: 按模式查找文件
Glob pattern="**/*.ts"常见模式:
- - 所有TypeScript文件
**/*.ts - - src目录下的React组件
src/**/*.tsx - - 任意位置的测试文件
**/test*.js
Searching Content
搜索文件内容
Primary Search: Use or for content searching. The built-in Grep tool is fallback-only.
pnpm search:code "query"Skill({ skill: 'ripgrep' })Grep Tool: Search file contents (fallback only — prefer or ripgrep skill first)
pnpm search:codeGrep pattern="function myFunc" path="/src"Options:
- : "content", "files_with_matches", or "count"
output_mode - ,
-A,-B: Context lines-C
优先搜索: 使用或进行内容搜索。内置的Grep工具仅作为备选方案。
pnpm search:code "query"Skill({ skill: 'ripgrep' })Grep工具: 搜索文件内容(仅作为备选——优先使用或ripgrep skill)
pnpm search:codeGrep pattern="function myFunc" path="/src"选项:
- : "content"、"files_with_matches"或"count"
output_mode - ,
-A,-B: 上下文行数-C
Writing Files
写入文件
Write Tool: Create or overwrite files
Write file_path="/path/to/file.txt" content="..."Edit Tool: Modify existing files
Edit file_path="/path/to/file.txt" old_string="..." new_string="..."Write工具: 创建或覆盖文件
Write file_path="/path/to/file.txt" content="..."Edit工具: 修改现有文件
Edit file_path="/path/to/file.txt" old_string="..." new_string="..."Directory Operations
目录操作
Bash Tool: For directory operations
bash
undefinedBash工具: 用于目录操作
bash
undefinedList directory
列出目录
ls -la /path/to/dir
ls -la /path/to/dir
Create directory
创建目录
mkdir -p /path/to/new/dir
mkdir -p /path/to/new/dir
Move/rename
移动/重命名
mv /old/path /new/path
</execution_process>
<best_practices>mv /old/path /new/path
</execution_process>
<best_practices>Common Workflows
常见工作流
Reading Multiple Files
读取多个文件
undefinedundefinedRead files in parallel (multiple Read calls in one message)
并行读取文件(在一条消息中调用多个Read)
Read file_path="/src/app.ts"
Read file_path="/src/config.ts"
Read file_path="/src/utils.ts"
undefinedRead file_path="/src/app.ts"
Read file_path="/src/config.ts"
Read file_path="/src/utils.ts"
undefinedSearch and Read
搜索并读取
undefinedundefined1. Find files
1. 查找文件
Glob pattern="**/*.config.ts"
Glob pattern="**/*.config.ts"
2. Read matching files
2. 读取匹配的文件
Read file_path="/path/from/glob/result"
undefinedRead file_path="/path/from/glob/result"
undefinedFind and Replace
查找并替换
undefinedundefined1. Search for pattern
1. 搜索模式
Grep pattern="oldFunction" path="/src"
Grep pattern="oldFunction" path="/src"
2. Edit each file
2. 编辑每个文件
Edit file_path="/src/file.ts" old_string="oldFunction" new_string="newFunction"
undefinedEdit file_path="/src/file.ts" old_string="oldFunction" new_string="newFunction"
undefinedBest Practices
最佳实践
- Read Before Edit: Always read a file before editing it
- Use Glob Over Bash: Prefer Glob to for file discovery
find - Search Tool Hierarchy: Use or
pnpm search:codefirst; use the Grep tool as fallback over raw bash grep onlySkill({ skill: 'ripgrep' }) - Parallel Reads: Read multiple files in one message for speed
- Verify Changes: Read file after editing to verify
</best_practices>
</instructions>
<examples>
<usage_example>
**Find and read all TypeScript files**:
Glob pattern="src/**/*.ts"- 编辑前先读取: 编辑文件前务必先读取文件内容
- 优先使用Glob而非Bash: 文件发现优先使用Glob而非
find - 搜索工具层级: 优先使用或
pnpm search:code;仅在必要时使用Grep工具作为原生bash grep的备选Skill({ skill: 'ripgrep' }) - 并行读取: 在一条消息中读取多个文件以提升速度
- 验证更改: 编辑后读取文件以验证更改
</best_practices>
</instructions>
<examples>
<usage_example>
**查找并读取所有TypeScript文件**:
Glob pattern="src/**/*.ts"Then read the results
然后读取结果
Read file_path="/src/app.ts"
</usage_example>
<usage_example>
**Search for a function and edit it**:
Grep pattern="export function oldName" path="/src"
Read file_path="/src/app.ts"
</usage_example>
<usage_example>
**搜索函数并编辑**:
Grep pattern="export function oldName" path="/src"
Found in /src/utils.ts:23
在/src/utils.ts:23找到
Edit file_path="/src/utils.ts" old_string="export function oldName" new_string="export function newName"
</usage_example>
</examples>Edit file_path="/src/utils.ts" old_string="export function oldName" new_string="export function newName"
</usage_example>
</examples>Rules
规则
- Always read files before editing
- Use built-in tools (Read, Glob, Grep) instead of bash equivalents
- Verify changes after editing
- 编辑文件前务必先读取
- 使用内置工具(Read、Glob、Grep)而非bash等效命令
- 编辑后验证更改
Memory Protocol (MANDATORY)
内存协议(强制要求)
Before starting:
bash
cat .claude/context/memory/learnings.mdAfter completing:
- New pattern ->
.claude/context/memory/learnings.md - Issue found ->
.claude/context/memory/issues.md - Decision made ->
.claude/context/memory/decisions.md
ASSUME INTERRUPTION: Your context may reset. If it's not in memory, it didn't happen.
开始前:
bash
cat .claude/context/memory/learnings.md完成后:
- 新模式 ->
.claude/context/memory/learnings.md - 发现问题 ->
.claude/context/memory/issues.md - 做出的决策 ->
.claude/context/memory/decisions.md
假设会被中断: 你的上下文可能会重置。如果内容不在内存中,就视为未发生过。