Skip to content
Back to skills

Local Files

ASecurity

读取、编辑、查找、搜索本地文件(read / edit / find / grep),用于改脚本、改配置、查内容、批量查找等本地文件任务;凭据与系统目录受保护。

  • 9 stars
  • 0 votes
  • 0 copies
  • 5 views
  • Added November 9, 2026
ai-agentsaws

Security analysis

A100/100

Pro scans all 3 files and shows the line behind each finding

Scanned November 9, 2026

npx -y skills add Eric-huang799/duplex --skill local-files --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Local Files?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Local Files
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/eric-huang799-local-files/badge)](https://www.skillsdirectory.com/skills/eric-huang799-local-files)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: 本地文件操作
description: 读取、编辑、查找、搜索本地文件(read / edit / find / grep),用于改脚本、改配置、查内容、批量查找等本地文件任务;凭据与系统目录受保护。
tools: [read_file, edit_file, glob, grep]
---

# 本地文件操作

当任务涉及**本地文件**(读取、修改、按内容查找)时使用本 skill。所有操作通过 `run_skill_script` 执行本目录下的 `filetool.ps1`。

**确认卡是正常流程**:每次执行前,Duplex 会向用户弹出一张确认卡(显示命令与工作目录)。等一下让用户点「允许执行」即可;用户拒绝时不要重试、不要换路径绕过,先询问用户意图。

**优先路径**:如果当前工具列表中已存在原生工具 `read_file` / `edit_file` / `glob` / `grep`(较新版本应用),优先直接使用它们;只有当这些工具不存在时,才使用下面的脚本方式。

## 读取 read

```
run_skill_script(name="本地文件操作", script="filetool.ps1", args=["read", "-Path", "C:\\绝对路径\\文件.txt", "-Offset", "1", "-Limit", "300"])
```

- 输出为带行号文本(`000123| 内容`)。默认从第 1 行、最多 400 行。
- 文件较大时用 `-Offset` / `-Limit` 分段读;输出有约 7000 字符上限,看到"还有后续内容"就继续读取下一段。
- 报"受保护路径"说明命中了安全黑名单(凭据/系统目录/Duplex 自身数据),这是预期行为,不要重试。
- 报"疑似二进制文件"时改用其他方式,不要强行按文本处理。

## 编辑 edit

编辑前**必须先 read 一次**,确认要替换的原文逐字一致(包括空白)。

简单替换(单行、不含换行、可以含空格但建议不含双引号):

```
run_skill_script(name="本地文件操作", script="filetool.ps1", args=["edit", "-Path", "C:\\路径\\文件.txt", "-Old", "旧文本", "-New", "新文本"])
```

- `-Old` 必须在文件中**唯一**;出现 0 处或多处都会报错:
  - 0 处 → 重新 read,把旧文本抄得更准确;
  - 多处 → 扩大旧文本上下文使其唯一,或追加 `"-All"`(全部替换,并在结果中说明)。
- **复杂内容**(含换行、双引号、或以 `-` 开头)不要走命令行参数,改用任务文件模式:
  1. 用 `write_file` 写一个 UTF-8 的 JSON 任务文件,例如:
     ```json
     {"path": "C:\\路径\\文件.txt", "old": "旧内容(可以多行)", "new": "新内容(可以多行,删除内容写空字符串)", "all": false}
     ```
  2. 再执行:
     ```
     run_skill_script(name="本地文件操作", script="filetool.ps1", args=["edit", "-Spec", "C:\\临时目录\\task.json"])
     ```
  3. 任务文件用完可留着不管(临时文件),下次需要时覆盖重写即可。
- 修改成功后**重新 read 一次**确认结果,再向用户汇报。

## 查找 find / 搜索 grep

```
run_skill_script(name="本地文件操作", script="filetool.ps1", args=["find", "-Path", "C:\\目录", "-Pattern", "*.py", "-Limit", "200"])
run_skill_script(name="本地文件操作", script="filetool.ps1", args=["grep", "-Path", "C:\\目录", "-Pattern", "正则表达式", "-Include", "*.ts", "-Limit", "100"])
```

- `find` 的 `-Pattern` 匹配**文件名**(如 `*.py`、`config*`);`grep` 的 `-Pattern` 是**区分大小写**的正则,`-Include` 可选,用于限定文件名。
- `grep` 输出格式为 `相对路径:行号: 内容`;结果有上限,提示截断时缩小 `-Path` 或加 `-Include`。
- 找不到内容属正常结果,直接汇报,不要反复重试同样的搜索。

## 边界与原则

- 本 skill 只提供**读、改、找**;不提供删除、移动、改权限等操作。用户要求这类操作时,先说明风险并征得明确同意后,再考虑用别的方式。
- 写入使用 UTF-8(有 BOM 的文件会保留 BOM);不改变文件其余内容。
- 保护目录(如 `.ssh`、`.aws`、`.gnupg`、`.config`、`.claude`、系统目录、Duplex 数据目录)读写都会被拒绝,属正常。
- 一次只做用户要求的事:不要顺手"优化"或重排无关内容。

Files in this skill

  • SKILL.md4.1 KB
  • filetool.ps114.4 KB
  • 使用说明.txt1.6 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.