generate-agents-md 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 generate-agents-md contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,311 @@
1
+ # generate-agents-md
2
+
3
+ `generate-agents-md` 是一个适用于 Codex 和 Claude Code 的 skill,用来为任意代码仓库生成或更新项目专属的 `AGENTS.md`。
4
+
5
+ 它采用 `SKILL.md` 目录结构发布。Codex 和 Claude Code 都可以读取这种以 Markdown 指令为核心的 skill 形式。
6
+
7
+ 它的核心思想很简单:
8
+
9
+ ```text
10
+ 用户的开发偏好 + 代码库里的真实事实 = 可执行的 AGENTS.md
11
+ ```
12
+
13
+ ## 背景
14
+
15
+ AI 编程工具越来越强,但一个常见问题是:每次进入新项目,AI 都需要重新理解项目结构、技术栈、命令、边界和团队偏好。
16
+
17
+ 如果没有清晰的 `AGENTS.md`,AI 很容易:
18
+
19
+ - 臆造不存在的命令、端口或目录
20
+ - 把多个独立项目误当成 monorepo
21
+ - 跨项目引入不该共享的代码
22
+ - 忽略已有公共模块、组件或工具函数
23
+ - 跑错测试命令,或者干脆不验证
24
+ - 生成一堆泛泛而谈、无法执行的项目规范
25
+
26
+ 手动为每个项目写 `AGENTS.md` 又很麻烦。尤其当你经常切换项目、维护多个仓库,或者希望把自己的开发习惯沉淀成可复用工作流时,这件事会变成重复劳动。
27
+
28
+ 所以我们做了 `generate-agents-md`。
29
+
30
+ ## 它解决什么问题
31
+
32
+ 这套工作流会指导 AI agent 先读取用户要求,再阅读仓库事实,最后生成真正贴合项目的 `AGENTS.md`。
33
+
34
+ 它适用于:
35
+
36
+ - 前端项目
37
+ - 后端项目
38
+ - 全栈项目
39
+ - 工具库
40
+ - 单体仓库
41
+ - monorepo
42
+ - 多个独立项目放在一起的仓库
43
+
44
+ 它关注的不是“写一份漂亮文档”,而是生成一份未来 AI agent 能照着工作的项目说明。
45
+
46
+ ## 优点
47
+
48
+ - **通用**:不绑定前端、后端或某个框架。
49
+ - **用户要求优先**:先保留你的开发偏好,再用代码库事实补全。
50
+ - **基于证据**:命令、端口、目录、框架和边界都来自仓库文件,不鼓励臆造。
51
+ - **支持多项目**:能判断是单项目、monorepo,还是多个独立项目放在一起。
52
+ - **支持嵌套说明**:只有当子项目确实有不同命令、技术栈或边界时,才建议生成 nested `AGENTS.md`。
53
+ - **短而可执行**:避免把 `AGENTS.md` 写成空泛的工程学长文。
54
+ - **尊重已有规范**:更新已有 `AGENTS.md` 时,会尽量保留有价值的内容。
55
+
56
+ ## 安装
57
+
58
+ ### Codex
59
+
60
+ 使用 Node / npx 安装到 Codex:
61
+
62
+ ```bash
63
+ npx github:<owner>/generate-agents-md --target codex
64
+ ```
65
+
66
+ 安装后重启 Codex。
67
+
68
+ 也可以使用 Codex skill installer:
69
+
70
+ ```bash
71
+ python3 ~/.codex/skills/.system/skill-installer/scripts/install-skill-from-github.py \
72
+ --repo <owner>/generate-agents-md \
73
+ --path skills/generate-agents-md
74
+ ```
75
+
76
+ 安装后重启 Codex。
77
+
78
+ ### Claude Code
79
+
80
+ Claude Code 会读取 `~/.claude/skills/<skill-name>/SKILL.md` 形式的用户级 skill。安装到 Claude Code:
81
+
82
+ ```bash
83
+ npx github:<owner>/generate-agents-md --target claude-code
84
+ ```
85
+
86
+ 安装后重启 Claude Code。
87
+
88
+ ### 同时安装到 Codex 和 Claude Code
89
+
90
+ ```bash
91
+ npx github:<owner>/generate-agents-md --target both
92
+ ```
93
+
94
+ ### 本地开发安装
95
+
96
+ ```bash
97
+ git clone https://github.com/<owner>/generate-agents-md.git
98
+ cd generate-agents-md
99
+ node scripts/install.mjs --target codex
100
+ node scripts/install.mjs --target claude-code
101
+ ```
102
+
103
+ 如果以后发布到 npm,也可以使用:
104
+
105
+ ```bash
106
+ npx generate-agents-md --target codex
107
+ ```
108
+
109
+ ## 使用方式
110
+
111
+ 在 Codex 中:
112
+
113
+ ```text
114
+ Use $generate-agents-md to generate AGENTS.md for this repository.
115
+
116
+ My requirements:
117
+ - keep instructions concise
118
+ - do not invent commands
119
+ - preserve existing project conventions
120
+ - create nested AGENTS.md files only when subprojects have different commands or boundaries
121
+ ```
122
+
123
+ 在 Claude Code 中,可以直接让 Claude 使用已安装的 skill:
124
+
125
+ ```text
126
+ Use the generate-agents-md skill to generate AGENTS.md for this repository.
127
+ ```
128
+
129
+ 中文也可以:
130
+
131
+ ```text
132
+ 使用 generate-agents-md skill 给这个仓库生成 AGENTS.md。
133
+
134
+ 我的要求:
135
+ - 多个项目要分开写
136
+ - 不要臆造命令和端口
137
+ - 保留已有项目规范
138
+ - 改完要写清楚验证方式
139
+ ```
140
+
141
+ ## 仓库结构
142
+
143
+ ```text
144
+ .
145
+ └── skills/
146
+ └── generate-agents-md/
147
+ ├── SKILL.md
148
+ └── agents/
149
+ └── openai.yaml
150
+ ```
151
+
152
+ ## 许可证
153
+
154
+ MIT
155
+
156
+ ---
157
+
158
+ # generate-agents-md
159
+
160
+ `generate-agents-md` is a skill for Codex and Claude Code that generates or updates project-specific `AGENTS.md` files for any codebase.
161
+
162
+ It is distributed as a `SKILL.md` directory. Codex and Claude Code can both use this Markdown-first skill format.
163
+
164
+ The core idea is simple:
165
+
166
+ ```text
167
+ User development preferences + repository facts = actionable AGENTS.md
168
+ ```
169
+
170
+ ## Background
171
+
172
+ AI coding tools are becoming more capable, but they still face a recurring problem: every time they enter a new repository, they need to rediscover the project structure, stack, commands, boundaries, and team preferences.
173
+
174
+ Without a clear `AGENTS.md`, AI agents can easily:
175
+
176
+ - invent commands, ports, or directories
177
+ - mistake colocated independent projects for a monorepo
178
+ - import code across boundaries that should remain separate
179
+ - ignore existing shared modules, components, or helpers
180
+ - run the wrong validation command, or skip validation entirely
181
+ - produce generic project rules that are not actually useful
182
+
183
+ Writing `AGENTS.md` manually for every project is repetitive. This is especially painful when you switch between many repositories or want to turn your development habits into a reusable workflow.
184
+
185
+ That is why `generate-agents-md` exists.
186
+
187
+ ## What It Solves
188
+
189
+ This workflow guides an AI agent to capture the user's requirements first, inspect the repository second, and then generate an `AGENTS.md` that fits the actual project.
190
+
191
+ It works for:
192
+
193
+ - frontend projects
194
+ - backend projects
195
+ - full-stack projects
196
+ - libraries
197
+ - single-project repositories
198
+ - monorepos
199
+ - repositories that colocate several independent projects
200
+
201
+ The goal is not to write pretty documentation. The goal is to create instructions that future AI coding agents can actually follow.
202
+
203
+ ## Strengths
204
+
205
+ - **Generic**: not tied to frontend, backend, or a specific framework.
206
+ - **User-first**: preserves your development preferences before filling in repository-specific details.
207
+ - **Evidence-based**: commands, ports, directories, frameworks, and boundaries should come from repository files.
208
+ - **Multi-project aware**: can distinguish between a single project, a monorepo, and colocated independent projects.
209
+ - **Nested instructions when useful**: only suggests nested `AGENTS.md` files when subprojects have meaningfully different commands, stacks, or boundaries.
210
+ - **Concise and operational**: avoids turning `AGENTS.md` into a long essay of generic engineering advice.
211
+ - **Respectful of existing docs**: preserves useful content when updating an existing `AGENTS.md`.
212
+
213
+ ## Install
214
+
215
+ ### Codex
216
+
217
+ Install into Codex with Node / npx:
218
+
219
+ ```bash
220
+ npx github:<owner>/generate-agents-md --target codex
221
+ ```
222
+
223
+ Restart Codex after installing the skill.
224
+
225
+ You can also use the Codex skill installer:
226
+
227
+ ```bash
228
+ python3 ~/.codex/skills/.system/skill-installer/scripts/install-skill-from-github.py \
229
+ --repo <owner>/generate-agents-md \
230
+ --path skills/generate-agents-md
231
+ ```
232
+
233
+ Restart Codex after installing the skill.
234
+
235
+ ### Claude Code
236
+
237
+ Claude Code reads user-level skills from `~/.claude/skills/<skill-name>/SKILL.md`. Install into Claude Code:
238
+
239
+ ```bash
240
+ npx github:<owner>/generate-agents-md --target claude-code
241
+ ```
242
+
243
+ Restart Claude Code after installing the skill.
244
+
245
+ ### Install into both Codex and Claude Code
246
+
247
+ ```bash
248
+ npx github:<owner>/generate-agents-md --target both
249
+ ```
250
+
251
+ ### Local development install
252
+
253
+ ```bash
254
+ git clone https://github.com/<owner>/generate-agents-md.git
255
+ cd generate-agents-md
256
+ node scripts/install.mjs --target codex
257
+ node scripts/install.mjs --target claude-code
258
+ ```
259
+
260
+ If this package is later published to npm, you can use:
261
+
262
+ ```bash
263
+ npx generate-agents-md --target codex
264
+ ```
265
+
266
+ ## Usage
267
+
268
+ In Codex:
269
+
270
+ ```text
271
+ Use $generate-agents-md to generate AGENTS.md for this repository.
272
+
273
+ My requirements:
274
+ - keep instructions concise
275
+ - do not invent commands
276
+ - preserve existing project conventions
277
+ - create nested AGENTS.md files only when subprojects have different commands or boundaries
278
+ ```
279
+
280
+ In Claude Code, ask Claude to use the installed skill:
281
+
282
+ ```text
283
+ Use the generate-agents-md skill to generate AGENTS.md for this repository.
284
+ ```
285
+
286
+ Chinese prompts work too:
287
+
288
+ ```text
289
+ 使用 generate-agents-md skill 给这个仓库生成 AGENTS.md。
290
+
291
+ 我的要求:
292
+ - 多个项目要分开写
293
+ - 不要臆造命令和端口
294
+ - 保留已有项目规范
295
+ - 改完要写清楚验证方式
296
+ ```
297
+
298
+ ## Repository Layout
299
+
300
+ ```text
301
+ .
302
+ └── skills/
303
+ └── generate-agents-md/
304
+ ├── SKILL.md
305
+ └── agents/
306
+ └── openai.yaml
307
+ ```
308
+
309
+ ## License
310
+
311
+ MIT
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "generate-agents-md",
3
+ "version": "0.1.0",
4
+ "private": false,
5
+ "description": "Install the generate-agents-md skill for Codex or Claude Code.",
6
+ "license": "MIT",
7
+ "type": "module",
8
+ "bin": {
9
+ "generate-agents-md": "./scripts/install.mjs"
10
+ },
11
+ "files": [
12
+ "scripts/",
13
+ "skills/",
14
+ "README.md",
15
+ "LICENSE"
16
+ ],
17
+ "keywords": [
18
+ "codex",
19
+ "claude-code",
20
+ "skill",
21
+ "agents.md",
22
+ "ai-agent",
23
+ "ai-coding",
24
+ "developer-tools"
25
+ ]
26
+ }
@@ -0,0 +1,76 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { cpSync, existsSync, mkdirSync, rmSync } from 'node:fs';
4
+ import { dirname, join, resolve } from 'node:path';
5
+ import { fileURLToPath } from 'node:url';
6
+ import { homedir } from 'node:os';
7
+
8
+ const __dirname = dirname(fileURLToPath(import.meta.url));
9
+ const rootDir = resolve(__dirname, '..');
10
+ const skillName = 'generate-agents-md';
11
+ const sourceDir = join(rootDir, 'skills', skillName);
12
+ const args = process.argv.slice(2);
13
+
14
+ function readTarget() {
15
+ const targetIndex = args.findIndex((arg) => arg === '--target' || arg === '-t');
16
+ if (targetIndex !== -1) {
17
+ return args[targetIndex + 1];
18
+ }
19
+
20
+ const inlineTarget = args.find((arg) => arg.startsWith('--target='));
21
+ if (inlineTarget) {
22
+ return inlineTarget.split('=')[1];
23
+ }
24
+
25
+ if (args.includes('--help') || args.includes('-h')) {
26
+ printHelp();
27
+ process.exit(0);
28
+ }
29
+
30
+ return 'codex';
31
+ }
32
+
33
+ function printHelp() {
34
+ console.log(`Usage:
35
+ generate-agents-md [--target codex|claude-code|both]
36
+
37
+ Targets:
38
+ codex Install to $CODEX_HOME/skills or ~/.codex/skills
39
+ claude-code Install to ~/.claude/skills
40
+ both Install to both locations
41
+ `);
42
+ }
43
+
44
+ function installTo(targetDir) {
45
+ const skillsDir = dirname(targetDir);
46
+ mkdirSync(skillsDir, { recursive: true });
47
+ rmSync(targetDir, { recursive: true, force: true });
48
+ cpSync(sourceDir, targetDir, { recursive: true });
49
+ console.log(`Installed ${skillName} to ${targetDir}`);
50
+ }
51
+
52
+ if (!existsSync(sourceDir)) {
53
+ console.error(`Skill source not found: ${sourceDir}`);
54
+ process.exit(1);
55
+ }
56
+
57
+ const target = readTarget();
58
+ const codexHome = process.env.CODEX_HOME || join(homedir(), '.codex');
59
+ const codexTarget = join(codexHome, 'skills', skillName);
60
+ const claudeTarget = join(homedir(), '.claude', 'skills', skillName);
61
+
62
+ if (!['codex', 'claude-code', 'both'].includes(target)) {
63
+ console.error(`Unknown target: ${target}`);
64
+ printHelp();
65
+ process.exit(1);
66
+ }
67
+
68
+ if (target === 'codex' || target === 'both') {
69
+ installTo(codexTarget);
70
+ }
71
+
72
+ if (target === 'claude-code' || target === 'both') {
73
+ installTo(claudeTarget);
74
+ }
75
+
76
+ console.log(target === 'claude-code' ? 'Restart Claude Code to pick up the new skill.' : 'Restart Codex or Claude Code to pick up the new skill.');
@@ -0,0 +1,104 @@
1
+ ---
2
+ name: generate-agents-md
3
+ description: Generate or update AGENTS.md files for any codebase by combining explicit user requirements with repository facts, including project boundaries, commands, conventions, tooling, validation workflows, and nested project instructions. Use when the user wants reusable agent instructions for a new or existing project.
4
+ ---
5
+
6
+ # Generate AGENTS.md
7
+
8
+ Use this skill to create concise, project-specific `AGENTS.md` files. The goal is to turn the user's preferences plus the repository's actual conventions into instructions a future coding agent can follow.
9
+
10
+ ## Core Principle
11
+
12
+ User requirements are first-class constraints. Repository facts refine and ground those requirements. Do not invent commands, ports, architecture, tools, or conventions.
13
+
14
+ ## Workflow
15
+
16
+ 1. Capture the user's explicit requirements before reading too much into the codebase.
17
+ 2. Inspect the repository shape with fast tools such as `rg --files`, `find`, and package/config reads.
18
+ 3. Determine project boundaries:
19
+ - single project
20
+ - true workspace or monorepo
21
+ - several independent projects colocated together
22
+ - library, application, service, or mixed repository
23
+ 4. Read representative evidence:
24
+ - root README and docs
25
+ - manifests such as `package.json`, `pyproject.toml`, `go.mod`, `Cargo.toml`, `pom.xml`, `build.gradle`, `.csproj`
26
+ - framework/build configs
27
+ - test, lint, formatter, CI, and container configs
28
+ - source entry points, routing, shared modules, packages, apps, services, or libraries
29
+ - existing `AGENTS.md`, `CONTRIBUTING.md`, coding standards, or architecture docs
30
+ 5. Identify practical instructions:
31
+ - project purpose and stack
32
+ - install/dev/build/test/lint/typecheck commands
33
+ - local ports and services when present
34
+ - important entry files and directories
35
+ - reusable modules, components, packages, helpers, or APIs
36
+ - generated/cache/vendor directories to avoid
37
+ - dependency and cross-boundary rules
38
+ - validation expectations and how to report failures
39
+ 6. Decide file placement:
40
+ - Use one root `AGENTS.md` when the repository has one coherent project.
41
+ - Use a short root `AGENTS.md` plus nested `AGENTS.md` files when subprojects have different commands, stacks, ownership boundaries, or conventions.
42
+ - Do not create nested files just because directories exist.
43
+ 7. Write or update the files.
44
+ 8. Summarize generated files, key assumptions, and any facts that could not be verified.
45
+
46
+ ## Content Shape
47
+
48
+ Prefer these sections when relevant:
49
+
50
+ - Project Context
51
+ - Work Boundaries
52
+ - Important Entrypoints
53
+ - Reuse Priorities
54
+ - Coding Rules
55
+ - Styling or Architecture Rules
56
+ - Data, API, or Dependency Rules
57
+ - Commands and Validation
58
+ - Local Ports or Services
59
+ - Files to Avoid
60
+
61
+ Keep each `AGENTS.md` operational and compact. Avoid generic advice unless the user asked for it or the repository clearly supports it.
62
+
63
+ ## User Requirements Handling
64
+
65
+ Preserve user preferences such as:
66
+
67
+ - coding style and architecture preferences
68
+ - testing or review expectations
69
+ - UI/design rules
70
+ - dependency restrictions
71
+ - security, performance, or accessibility expectations
72
+ - generated-file handling
73
+ - forbidden operations
74
+ - multi-project boundaries
75
+
76
+ If a user requirement conflicts with repository evidence, do not silently resolve it. Explain the conflict and choose the safer, less destructive option.
77
+
78
+ ## Detection Guidance
79
+
80
+ - If a root workspace file exists, treat the repository as a workspace unless project files show the apps are intentionally independent.
81
+ - If subdirectories each have their own manifest and lockfile, consider whether they are colocated independent projects.
82
+ - Commands should come from manifests, Makefiles, task runners, CI, docs, or obvious framework conventions. Mark uncertain items as not found instead of inventing them.
83
+ - Local ports should come from config files, scripts, docs, compose files, or environment examples.
84
+ - Generated folders such as `node_modules`, `.next`, `dist`, `build`, `.turbo`, `.umi`, `target`, `.venv`, `__pycache__`, and coverage output should usually be excluded from inspection and editing.
85
+
86
+ ## Quality Bar
87
+
88
+ Good `AGENTS.md` files are:
89
+
90
+ - specific to the repository
91
+ - short enough to be read every time
92
+ - clear about boundaries and commands
93
+ - grounded in evidence
94
+ - faithful to the user's requirements
95
+ - useful for day-to-day coding, review, testing, and maintenance
96
+
97
+ Avoid:
98
+
99
+ - long essays
100
+ - generic best-practice dumps
101
+ - invented commands or ports
102
+ - broad rewrite instructions unless the user asked for them
103
+ - duplicating the same detailed rules in every nested file
104
+ - overwriting existing project instructions without preserving useful content
@@ -0,0 +1,4 @@
1
+ interface:
2
+ display_name: "Generate AGENTS.md"
3
+ short_description: "Create repo-specific agent instructions."
4
+ default_prompt: "Use $generate-agents-md to generate or update AGENTS.md from my requirements and this repository's conventions."