verify-directory-structure-parallel-audit
它能做什么
这个技能检查文件夹和文件是否存在且可读,然后将文件分组一起读取。适合需要更快完成较大代码库审计的人。
适用场景
- ✓当文件操作失败,需要先检查文件夹时。
- ✓当你需要一次性审计大量源文件时。
- ✓当你想检查整个项目中的 TypeScript 导入模式时。
技能链接
https://github.com/HKUDS/AgentPilot/blob/main/openspace/legacy/v1/showcase/skills/verify-directory-structure-parallel-audit/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请帮我检查项目文件夹,然后审查所有源文件中的导入。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体列出文件夹,建立需要检查的文件列表,分批读取,然后审查 TypeScript 的导入模式。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Verify Directory Structure — Parallel Audit
This skill provides a systematic approach to diagnosing file access issues and auditing source trees efficiently. It extends basic directory verification with parallel batch file reading (dramatically reducing iteration count when many files must be inspected) and a dedicated TypeScript import validation phase that catches a common class of structural bugs.
Steps
Phase 1 — Directory Verification
Identify Target Paths: Collect every file or directory path involved in the operation. Prefer absolute paths to eliminate ambiguity.
Enumerate with
list_dir: Calllist_diron each relevant directory. Record all file names, sizes, and modification dates. This is your ground truth before touching any file.Verify Existence & Permissions: Confirm the directory exists and that the current user has read (and, if needed, write/execute) permissions. If a directory is missing, create it before proceeding. If permissions are insufficient, adjust them before retrying.
Build a File Manifest: From the
list_diroutput, compile the complete list of files to be audited. Group them logically (e.g., by subdirectory or file type) so they can be read in parallel batches.
Phase 2 — Parallel Batch File Reading
Why this matters: Reading files sequentially costs one iteration per file. Reading them in parallel batches collapses N files into ⌈N/batch_size⌉ iterations — a significant speedup when auditing dozens of files.
Determine Batch Size: Default to reading 5–10 files per batch. Reduce the batch size if individual files are very large; increase it for small config/index files.
Issue Parallel
read_fileCalls: Within each batch, invokeread_filefor all files simultaneously (a single iteration). Do not wait for one file before requesting the next within the same batch.Batch 1 (parallel): read_file(src/components/A.tsx) read_file(src/components/B.tsx) read_file(src/components/C.tsx) read_file(src/components/D.tsx) read_file(src/components/E.tsx) Batch 2 (parallel): read_file(src/components/F.tsx) ...Collect & Triage Results: After each batch completes, scan results for errors (file-not-found, permission denied) and flag them immediately. Do not abort the remaining batches; continue and aggregate all findings.
Re-verify Missing Files: For any file reported as missing, re-run
list_diron its parent directory to confirm whether the file truly does not exist or whether the path was wrong. Correct the path and retry the single file if necessary.
Phase 3 — TypeScript Import Validation
This phase targets a common class of structural bugs found when auditing TypeScript source trees.
Identify Import Statements: For every
.ts/.tsxfile read in Phase 2, extract allimportlines.Classify Import Kind — Value vs. Type:
Pattern Correct usage import Foo from '...'Runtime value (class, function, object) import { Foo } from '...'Runtime value export import type Foo from '...'Type-only import (erased at compile time) import type { Foo } from '...'Type-only named import import { type Foo } from '...'Inline type modifier (TS 4.5+) Flag Value Imports Used Only as Types: If an identifier imported without
typeis used only in type positions (: Foo,as Foo,implements Foo, generic parameters), it should be converted toimport type. This prevents accidental runtime dependencies and satisfiesverbatimModuleSyntax/isolatedModulescompiler flags.// ❌ Before — value import used only as a type import { UserProfile } from './types'; const handler = (u: UserProfile) => { ... }; // ✅ After — type-only import import type { UserProfile } from './types'; const handler = (u: UserProfile) => { ... };Flag Duplicate Imports: Detect cases where the same module is imported more than once in a file (often from copy-paste). Merge them into a single import statement.
// ❌ Duplicate import { A } from './utils'; import { B } from './utils'; // ✅ Merged import { A, B } from './utils';Verify Barrel / Index Exports: When
常见问题
为什么要分批读取文件?
一次读取多个文件比逐个读取所需的步骤更少。
它检查文件夹的哪些内容?
它检查每个文件夹是否存在,以及用户是否有读取权限,并在需要时创建缺失的文件夹。
它会修改文件吗?
审计步骤只读取文件。任何编辑都是单独的、明确的步骤。
详情
作者的原始描述
Diagnose and resolve file access issues by verifying directory structure, then reading multiple files in parallel batches for efficient auditing, with built-in guidance for validating TypeScript import patterns.
repo: HKUDS/AgentPilot
热度
- GitHub 星标
- 7.8k
- 排名
- #13089
- 许可证
- MIT
- 更新时间
- 2026/11/1
评论
- …
同一仓库的更多技能
agentpilot
7.8k帮你的智能体准备任务并运行 AgentPilot 循环,逐步改进项目:循环会提出修改、测试修改并为其打分。
openspace
7.8k帮你的智能体设置 OpenSpace,这是一个用于存储和获取智能体技能的工具,并通过 MCP 将其连接到你的 AI 应用。
rsi-arena
7.8k帮你的智能体设置并运行标准 AI 基准测试,例如 AIME 和 Terminal-Bench,用来比较不同的改进方法。
experiment-guide
7.8k帮你的智能体规划小型实验、阅读实验结果并记录发现,同时研究如何改进一个程序。