project-structure
它能做什么
这个技能为代码项目生成一个压缩的地图文件,列出其文件、导出的名称和函数签名。适合希望智能体一次性理解整个代码库的开发者。
适用场景
- ✓你想概览一个大型 TypeScript 或 Swift 项目的时候。
- ✓你在查找重复代码,或计划重构的时候。
- ✓你想把完整的项目地图交给另一个智能体的时候。
技能链接
https://github.com/steipete/agent-scripts/blob/main/skills/project-structure/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请为这个 TypeScript 项目做一份紧凑的地图,方便我们查找其中的重复代码。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会对项目文件夹运行随附的脚本,生成一份包含文件、符号和签名的地图文件,并报告结果的大小。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Project Structure
Compress a TS or Swift repo into one map file an agent can load whole. Backed by map.ts next to this file. TS: parse-only TS compiler, no type-check; ~8k files in ~5s; resolves the typescript package from the target repo, falling back to this skill dir. Swift: zero-dependency regex/brace-depth scanner built into map.ts (no typescript needed for pure-Swift repos). Requires Node >= 23.6 (native type stripping) or npx tsx. .ts/.tsx and .swift files are detected by extension; a repo may mix both.
Run
node <this-skill-dir>/map.ts <repoRoot> [flags]
<this-skill-dir> is the base directory of this skill as announced when the skill loads (canonical: ~/Projects/agent-scripts/skills/project-structure).
Output: one map file (default project-structure-map.txt in cwd) plus a JSON stats line (files, symbols, bytes, approxTokens) on stdout.
Flags
--out <file>— output path.--mode dense|skeleton|exports|sigs|full— defaultdense.dense: dir-grouped, one line per file:file fn:a,b ty:T cl:C c:x re:./y. Recon tier. File extensions are stripped for compactness, so a same-basename TS and Swift file in one dir share a line prefix (theoretical in practice; grep the repo to disambiguate).skeleton: one symbol per line, names only.exports: exported symbols with full typed signatures, type bodies, first doc-comment line. Refactor-decision tier. TS-only — Swift files fall back to their dense-style line (no fabricated signatures).sigs: exports but type/interface bodies collapsed to member names (only ~10% smaller than exports; rarely worth it). TS-only, same Swift fallback.full: exports + non-exported top-level symbols (markedinternal; internal consts appear only when function-valued or explicitly typed — untyped internal consts are filtered as noise). TS-only, same Swift fallback.
--include a,b,c— paths to map, relative to repoRoot (default: all top-level dirs, minus skips/boundaries). Accepts nested paths, not just top-level dirs:--include src/channels/turnmaps exactly that subtree. Headers stay repoRoot-relative, so running from repo root with--include <subsystem>is the recommended way to map a subsection.--boundary x,y— dirs listed as boundary index only: child module names + one-linepackage.jsondescriptions, no symbol content. Use for plugin/extension trees.--include-tests— keep test files and test-support infra (default: both excluded; Swift test detection is path-based:Tests?/dirs and*Tests.swift).--no-docs— strip doc comments (saves ~13% on typed modes).--fn-consts-only— drop non-function const exports (on Swift files: drops every let/var symbol — closure-valued consts are indistinguishable without type info). Caution: silently drops files whose only exports are consts (plugin definition objects, schemas, registries). Prefer keeping consts indense(names are cheap).--re-counts— collapse re-export path lists to a count (dense; saves ~10%).--max-per-kind N— cap each symbol-kind list per file with+noverflow marker (dense; 10–12 is safe).--members— Swift only (ignored for TS files): additionally emit one-level-deep methods/properties asType.member; extension members appear under their target type.--public-only— Swift only (ignored for TS files): keep only symbols whose written access isopen/public.
When --include is absent, source files sitting directly in repoRoot are scanned too (so pointing repoRoot at a leaf source dir works); with --include, only the listed paths are walked.
Swift specifics
Zero-dependency line scanner (lexical masking of comments/strings + brace-depth tracking), validated 1:1 against SourceKitten on 1,850 files across two real repos (100% top-level symbol agreement) at ~100× SourceKitten's speed. Known limitations (accepted tradeoffs of the parserless design): one declaration per line is assumed — a member on the same line as its type (struct Box { var v = 1 }) or a second semicolon-separated declaration is not emitted; bare /…/ regex literals are not masked (lexically ambiguous with division), so a brace inside one can desync depth for the rest of that file — extended #/…/# literals are masked correctly; comments or raw/multiline literals nested inside string interpolations, emoji identifiers, and #if branches whose alternative headers declare differently named containers are best-effort (sam
常见问题
它支持哪些语言?
TypeScript 和 Swift,包括同时包含两者的代码仓库。
它会检查类型吗?
不会。TypeScript 部分只做解析,不运行类型检查。
需要安装什么?
Node 23.6 或更新版本,或名为 tsx 的工具。
详情
作者的原始描述
Generate a single-file compressed symbol map of a TypeScript or Swift repository — files, exported symbols, typed signatures, plugin boundaries — sized to fit an LLM context window. Use for whole-project reasoning: duplication hunting, refactor planning, architecture recon, or feeding another agent a full-project map.
repo: steipete/agent-scripts
热度
- GitHub 星标
- 7.4k
- 排名
- #13242
- 许可证
- MIT
- 更新时间
- 2026/10/30
评论
- …
同一仓库的更多技能
beeper
7.4k帮你的智能体搜索本地 Beeper 聊天记录,找到消息,并判断模糊线索指的是哪个聊天或联系人。
cloudflare-registrar
7.4k帮你的智能体查询 Cloudflare Registrar 的域名价格和可用性,并在确认后注册或列出域名。
codexbar
7.4k帮你的智能体查看你在 Codex、Claude、Kimi 等 AI 服务中还剩多少用量,包括限额、额度和重置时间。
create-cli
7.4k帮你的智能体设计命令行工具的命令、参数、帮助文本、输出和错误提示,让人和脚本都能顺利使用。