fa-mcp-sdk 0.4.52 → 0.4.54
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/README.md +1 -1
- package/cli-template/.claude/settings.json +3 -1
- package/cli-template/.claude/skills/edit-claude-files/SKILL.md +46 -0
- package/cli-template/.claude/skills/readme-generator/README.md +1 -0
- package/cli-template/.claude/skills/readme-generator/SKILL.md +237 -0
- package/cli-template/.claude/skills/readme-generator/reference/best-practices.md +218 -0
- package/cli-template/.claude/skills/readme-generator/reference/satellite-templates.md +534 -0
- package/cli-template/.claude/skills/readme-generator/reference/templates.md +385 -0
- package/cli-template/CLAUDE.md +5 -19
- package/cli-template/FA-MCP-SDK-DOC/00-FA-MCP-SDK-index.md +1 -1
- package/cli-template/FA-MCP-SDK-DOC/02-1-tools-and-api.md +60 -0
- package/cli-template/FA-MCP-SDK-DOC/04-authentication.md +10 -8
- package/cli-template/README.md +2 -1
- package/cli-template/SKILL_README.md +40 -0
- package/cli-template/package.json +1 -1
- package/cli-template/prompt-example-new-MCP.md +3 -2
- package/config/custom-environment-variables.yaml +4 -3
- package/config/default.yaml +20 -18
- package/config/local-test.yaml +44 -0
- package/dist/core/_types_/config.d.ts +8 -5
- package/dist/core/_types_/config.d.ts.map +1 -1
- package/dist/core/auth/admin-auth.d.ts +12 -5
- package/dist/core/auth/admin-auth.d.ts.map +1 -1
- package/dist/core/auth/admin-auth.js +37 -25
- package/dist/core/auth/admin-auth.js.map +1 -1
- package/dist/core/bootstrap/startup-info.d.ts.map +1 -1
- package/dist/core/bootstrap/startup-info.js +13 -5
- package/dist/core/bootstrap/startup-info.js.map +1 -1
- package/dist/core/mcp/readme-assembler.d.ts +20 -0
- package/dist/core/mcp/readme-assembler.d.ts.map +1 -0
- package/dist/core/mcp/readme-assembler.js +88 -0
- package/dist/core/mcp/readme-assembler.js.map +1 -0
- package/dist/core/mcp/resources.d.ts.map +1 -1
- package/dist/core/mcp/resources.js +2 -1
- package/dist/core/mcp/resources.js.map +1 -1
- package/dist/core/web/admin-router.js +2 -2
- package/dist/core/web/admin-router.js.map +1 -1
- package/dist/core/web/home-api.d.ts.map +1 -1
- package/dist/core/web/home-api.js +13 -5
- package/dist/core/web/home-api.js.map +1 -1
- package/dist/core/web/server-http.d.ts.map +1 -1
- package/dist/core/web/server-http.js +1 -2
- package/dist/core/web/server-http.js.map +1 -1
- package/dist/core/web/static/home/index.html +2 -2
- package/dist/core/web/static/home/script.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -219,7 +219,7 @@ Note: The `dist/` directory (compiled JavaScript) is created after running `npm
|
|
|
219
219
|
`http://localhost:3000` with:
|
|
220
220
|
- MCP endpoints at `/mcp/*`
|
|
221
221
|
- Admin panel for generating access tokens at `/admin`
|
|
222
|
-
- When `
|
|
222
|
+
- When `adminPanel.authType` includes `jwtToken`, the JWT **must** carry `allow: 'gen-token'`
|
|
223
223
|
in its payload to be accepted. Tokens without this claim (e.g. the short-lived JWT
|
|
224
224
|
auto-generated for the Agent Tester page) are rejected — this prevents them from
|
|
225
225
|
being replayed to mint arbitrary long-lived tokens. `permanentServerTokens` and
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: edit-claude-files
|
|
3
|
+
description: "Protocol for editing or creating any file under .claude/ (SKILL.md, scripts, hooks, agents, settings.json, etc.). Use whenever a file path starts with .claude/ — direct Write/Edit is blocked by settings.json, so changes MUST go through the scripts/fcp.js temp-copy workflow."
|
|
4
|
+
allowed-tools: Read, Write, Edit, MultiEdit, Bash(node scripts/fcp.js *), Bash(rm:*)
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Editing files in `.claude/`
|
|
8
|
+
|
|
9
|
+
**Scope of this rule — read carefully.** It applies to **every file under `.claude/`** — not only
|
|
10
|
+
`SKILL.md`. This includes scripts in `.claude/skills/<skill>/scripts/`, hooks in `.claude/hooks/`,
|
|
11
|
+
agent configs in `.claude/agents/`, supporting reference files, `settings.json`, and anything else
|
|
12
|
+
inside the directory. Claude Code watches the whole tree and reloads on change; direct writes risk
|
|
13
|
+
partial reads and inconsistent state during multi-edit sessions.
|
|
14
|
+
|
|
15
|
+
To enforce this, `settings.json` denies the `Write` and `Edit` tools on `.claude/**` outright.
|
|
16
|
+
Attempting a direct edit will fail the permission check — that is intentional, not a bug.
|
|
17
|
+
|
|
18
|
+
**Protocol — every file, every time:**
|
|
19
|
+
|
|
20
|
+
1. **Copy** the target file to a temp location outside `.claude/` (works for any file type: md, js,
|
|
21
|
+
json, cjs, …):
|
|
22
|
+
```bash
|
|
23
|
+
node scripts/fcp.js tmp-edit.md .claude/skills/<skill-name>/SKILL.md
|
|
24
|
+
node scripts/fcp.js tmp-helper.js .claude/skills/<skill-name>/scripts/helper.js
|
|
25
|
+
```
|
|
26
|
+
2. **Edit** the temp file — make ALL changes there (multiple Edit calls are fine).
|
|
27
|
+
3. **Save** atomically via the helper script (same command, reversed argument order):
|
|
28
|
+
```bash
|
|
29
|
+
node scripts/fcp.js .claude/skills/<skill-name>/SKILL.md tmp-edit.md
|
|
30
|
+
node scripts/fcp.js .claude/skills/<skill-name>/scripts/helper.js tmp-helper.js
|
|
31
|
+
```
|
|
32
|
+
4. **Remove** the temp file:
|
|
33
|
+
```bash
|
|
34
|
+
rm tmp-edit.md
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**Creating a new file in `.claude/`** — same protocol, just start from an empty temp file:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
# Write the new file somewhere OUTSIDE .claude/, then fcp.js it in:
|
|
41
|
+
node scripts/fcp.js .claude/skills/<skill-name>/scripts/new-script.js tmp-new-script.js
|
|
42
|
+
rm tmp-new-script.js
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
CRITICAL: Never use `Edit` or `Write` directly on files inside `.claude/` — always go through the
|
|
46
|
+
temp-copy workflow above. This covers SKILL.md, scripts, hooks, agents, settings — everything.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
https://www.skillsdirectory.com/skills/armanzeroeight-readme-generator?utm_source=chatgpt.com
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: readme-generator
|
|
3
|
+
description: Generates structured, user-friendly README.md for MCP servers built with fa-mcp-sdk. Detects which SDK subsystems are enabled (Consul, AD, DB, Admin Panel, Agent Tester, Webhooks, etc.) and which project-specific features exist, then decides which sections to inline vs. move to satellite readme-docs/*.md files. Use when creating or refreshing README for an fa-mcp-sdk-based MCP server project.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# MCP Server README Generator
|
|
7
|
+
|
|
8
|
+
Generates a `README.md` tailored to MCP servers built on `fa-mcp-sdk`. The README answers three
|
|
9
|
+
progressive questions — *what is this?*, *how do I use it?*, *how do I operate it?* — without
|
|
10
|
+
drowning casual readers in operational detail.
|
|
11
|
+
|
|
12
|
+
## Philosophy
|
|
13
|
+
|
|
14
|
+
Three-level information hierarchy:
|
|
15
|
+
|
|
16
|
+
**Level 1 — What & how to use it (first 30 seconds for the consumer)**
|
|
17
|
+
|
|
18
|
+
- What this MCP server is for
|
|
19
|
+
- What tools it exposes
|
|
20
|
+
- How to connect from Claude Code / Claude Desktop / Qwen Code (the simplest path)
|
|
21
|
+
|
|
22
|
+
**Level 2 — Features & basics (interested reader)**
|
|
23
|
+
|
|
24
|
+
- Enabled fa-mcp-sdk subsystems, project-specific capabilities, transports, essential config
|
|
25
|
+
|
|
26
|
+
**Level 3 — Operations (deployer / maintainer)**
|
|
27
|
+
|
|
28
|
+
- Build & run, full configuration, deep technical topics
|
|
29
|
+
|
|
30
|
+
Level 1 and 2 live in the main README. Level 3 content longer than ~15 lines moves to satellite
|
|
31
|
+
Markdown files under `readme-docs/`. The main README stays scannable; deep detail is one click away.
|
|
32
|
+
|
|
33
|
+
## The `readme-docs/` folder is load-bearing
|
|
34
|
+
|
|
35
|
+
Satellite Markdown files **must** live in `readme-docs/` at the project root. The fa-mcp-sdk
|
|
36
|
+
`doc://readme` MCP resource looks for exactly that folder name: on server start it reads
|
|
37
|
+
`README.md`, finds every link pointing into `readme-docs/`, appends those satellite files (each
|
|
38
|
+
separated by `\n\n---\n\n`) and rewrites the in-text links to `See "<heading>" below` so the
|
|
39
|
+
assembled document reads naturally.
|
|
40
|
+
|
|
41
|
+
This means:
|
|
42
|
+
|
|
43
|
+
- The entire documentation is delivered through `doc://readme` as one searchable markdown
|
|
44
|
+
document — essential for the MCP registry's RAG indexing.
|
|
45
|
+
- Any satellite file *not* linked from `README.md` is **not** included in the resource. If you
|
|
46
|
+
add a new `readme-docs/*.md` file, link to it from the main README.
|
|
47
|
+
- Do not rename the folder. Any other name (`docs/`, `doc/`, `readme-parts/` etc.) will be
|
|
48
|
+
ignored by the SDK and the satellite content will not reach RAG.
|
|
49
|
+
|
|
50
|
+
## Dynamic detection is mandatory
|
|
51
|
+
|
|
52
|
+
The set of satellite files is **not fixed**. The skill inventories the project, decides per feature
|
|
53
|
+
whether it is enabled, and only then produces the matching README sections and `readme-docs/*.md` files.
|
|
54
|
+
**Do not create a satellite file for a disabled feature.** Do not emit empty sections.
|
|
55
|
+
|
|
56
|
+
## Workflow
|
|
57
|
+
|
|
58
|
+
### Step 1 — Inventory the project
|
|
59
|
+
|
|
60
|
+
Collect, from the actual repository:
|
|
61
|
+
|
|
62
|
+
**Metadata**
|
|
63
|
+
|
|
64
|
+
- `package.json` → `name`, `version`, `description`, `dependencies`
|
|
65
|
+
- Git remote URL, license file
|
|
66
|
+
|
|
67
|
+
**Configuration** (merge `config/default.yaml` with `config/local.yaml` if present)
|
|
68
|
+
|
|
69
|
+
- `webServer.port` — default port for Quick Start commands
|
|
70
|
+
- Custom per-request header names (grep `x-<prefix>-` in `src/`)
|
|
71
|
+
- Enabled/disabled status for each optional subsystem (see table below)
|
|
72
|
+
|
|
73
|
+
**Code surface**
|
|
74
|
+
|
|
75
|
+
- `src/tools/` — tool list + each tool's domain group
|
|
76
|
+
- `src/start.ts` — transports registered, custom auth validators
|
|
77
|
+
- `src/api/` — existence + routes (custom REST API)
|
|
78
|
+
- `src/prompts/` — existence + prompt list
|
|
79
|
+
- `src/custom-resources.ts` — existence
|
|
80
|
+
- `.claude/skills/*/SKILL.md` — catalog of in-project skills
|
|
81
|
+
|
|
82
|
+
**Optional fa-mcp-sdk subsystems — detect each**
|
|
83
|
+
|
|
84
|
+
| Subsystem | Detect via | Enabled marker |
|
|
85
|
+
|----------------------------------|------------------------------------------------------|-------------------------|
|
|
86
|
+
| Consul (service discovery) | `consul.service.enable` | `true` |
|
|
87
|
+
| Active Directory (group checks) | `ad.domains.*` | non-empty |
|
|
88
|
+
| PostgreSQL (with pgvector) | `db.*` + imports from `pg-db.js` | both present |
|
|
89
|
+
| Custom REST API | `src/api/` + `webServer.customApi.*` | folder non-empty |
|
|
90
|
+
| Prompts | `src/prompts/` | folder non-empty |
|
|
91
|
+
| Custom Resources | `src/custom-resources.ts` | file exists |
|
|
92
|
+
| Admin Panel (token UI) | `adminPanel.enabled` | `true` |
|
|
93
|
+
| Agent Tester + Headless API | `agentTester.enabled` | `true` |
|
|
94
|
+
| Swagger UI | `swagger.enabled` | `true` |
|
|
95
|
+
| Cache (node-cache) | `cache.*` referenced in `src/` | used |
|
|
96
|
+
| Webhook callback (`x-web-hook`) | `x-web-hook` in `src/` OR tool handler returns `hook` | used |
|
|
97
|
+
| Impersonation (`x-on-behalf-of-user`) | `impersonalizationPlugin.*` in config | present |
|
|
98
|
+
| JWT auth | `webServer.auth.jwt.*` or `webServer.genJwtApiEnable` | present/true |
|
|
99
|
+
| Configurable tool set | `<upstream>.usedInstruments` | present |
|
|
100
|
+
|
|
101
|
+
**Project-specific capabilities** — anything non-trivial not covered above:
|
|
102
|
+
|
|
103
|
+
- Fuzzy entity resolution, batch-operation limits, per-endpoint caching strategy,
|
|
104
|
+
API-version auto-detection (Cloud vs Server), automatic labeling of created entities,
|
|
105
|
+
required-fields pre-flight validation, content-format conversion (Markdown ↔ ADF / Storage
|
|
106
|
+
Format), etc.
|
|
107
|
+
- Any tool-group-specific quirks worth highlighting.
|
|
108
|
+
|
|
109
|
+
Record all findings in a working note — they drive the decisions in the next step.
|
|
110
|
+
|
|
111
|
+
### Step 2 — Classify findings: drop / inline / satellite
|
|
112
|
+
|
|
113
|
+
For each finding, pick placement:
|
|
114
|
+
|
|
115
|
+
- **Drop** — feature not used; no section, no satellite file.
|
|
116
|
+
- **Inline** — description ≤ ~15 lines. Put a short subsection in the main README.
|
|
117
|
+
- **Satellite** — description > ~15 lines, OR the topic contains reference tables, priority rules,
|
|
118
|
+
request/response schemas, long examples. Create `readme-docs/<kebab-name>.md` and link to it from the
|
|
119
|
+
main README with a 2–3 sentence summary.
|
|
120
|
+
|
|
121
|
+
**Always satellite** (do not inline even if short):
|
|
122
|
+
|
|
123
|
+
- Authentication resolution order / priority tables
|
|
124
|
+
- Webhook body schema + per-tool hook priority rules
|
|
125
|
+
- Headless Agent Tester full argument list and scenario matrix
|
|
126
|
+
- Full configuration reference tables (> 15 parameters)
|
|
127
|
+
- Consul / AD / Database detailed setup
|
|
128
|
+
|
|
129
|
+
**Always inline in the main README** (never moved out):
|
|
130
|
+
|
|
131
|
+
- Tool list (grouped table) — users need to see the API surface
|
|
132
|
+
- Quick Start commands
|
|
133
|
+
- **MCP Client Integration** JSON snippets (Claude Code / Desktop / Qwen Code) — adapted to this
|
|
134
|
+
server's actual custom header names
|
|
135
|
+
- Key Features bullet list
|
|
136
|
+
|
|
137
|
+
### Step 3 — Build main README section list
|
|
138
|
+
|
|
139
|
+
Canonical section order. Include only sections backed by actual findings; omit anything empty.
|
|
140
|
+
|
|
141
|
+
1. **Title + one-line description** (from `package.json`)
|
|
142
|
+
2. **Badges** — build, license, language, key stack badges via shields.io
|
|
143
|
+
3. **Overview** — 2–4 sentences. Answers: what is this, for whom, core value
|
|
144
|
+
4. **Tools** — grouped table, `## Tools (<count>)` with per-domain `###` subsections
|
|
145
|
+
5. **Quick Start** — install, run, minimal verification (3 short steps)
|
|
146
|
+
6. **MCP Client Integration** — Claude Code (HTTP), Claude Desktop (STDIO + `mcp-remote` /
|
|
147
|
+
direct STDIO), Qwen Code. Use the server's actual custom header names
|
|
148
|
+
(e.g. `x-jira-token`, `x-wiki-username`)
|
|
149
|
+
7. **Key Features** — 5–8 bullets. Include enabled SDK subsystems and project-specific capabilities
|
|
150
|
+
8. **Transports** — short bulleted list with endpoints (`/mcp`, `/api/*`, `/docs`, `/health`,
|
|
151
|
+
`/admin`, `/agent-tester`, STDIO for Claude Desktop)
|
|
152
|
+
9. **Configuration Basics** — 5–10 most important keys in a compact table; link to
|
|
153
|
+
`readme-docs/configuration.md` when the full reference is long
|
|
154
|
+
10. **Build & Run / Deployment** — minimal commands, environment variables
|
|
155
|
+
11. **Authentication** — 2–4 sentences + link to `readme-docs/authentication.md` (satellite is mandatory
|
|
156
|
+
when non-trivial auth is present)
|
|
157
|
+
12. **Feature sections (dynamic)** — one short subsection per enabled optional subsystem and per
|
|
158
|
+
notable project-specific capability. Each: 2–3 sentences + link to its `readme-docs/*.md` when a
|
|
159
|
+
satellite is warranted. Typical candidates:
|
|
160
|
+
- Consul service discovery → `readme-docs/consul.md`
|
|
161
|
+
- Active Directory integration → `readme-docs/active-directory.md`
|
|
162
|
+
- PostgreSQL / pgvector → `readme-docs/database.md`
|
|
163
|
+
- Custom REST API → link to Swagger UI (`/docs`) and/or `readme-docs/api.md`
|
|
164
|
+
- Admin panel → inline or `readme-docs/admin-panel.md`
|
|
165
|
+
- Agent Tester + Headless API → `readme-docs/testing.md`
|
|
166
|
+
- Webhook callback → `readme-docs/webhooks.md`
|
|
167
|
+
- Impersonation → `readme-docs/impersonation.md`
|
|
168
|
+
- Project-specific: fuzzy resolution, caching strategy, API version detection, batch limits,
|
|
169
|
+
content-format conversion, etc. → `readme-docs/<topic>.md` as appropriate
|
|
170
|
+
13. **Skills** — short paragraph linking to `SKILL_README.md` in repo root (kept at root by
|
|
171
|
+
convention established in existing fa-mcp-sdk projects)
|
|
172
|
+
14. **Stack** — 4–7 bullets: framework (`fa-mcp-sdk`), transport, language, key libs
|
|
173
|
+
15. **License**
|
|
174
|
+
|
|
175
|
+
### Step 4 — Generate `README.md`
|
|
176
|
+
|
|
177
|
+
Apply the canonical section order from Step 3. Respect these rules:
|
|
178
|
+
|
|
179
|
+
- H1 is the project name only — no duplicate title in the next line.
|
|
180
|
+
- Tool table column widths consistent within the file. Tool names as inline code.
|
|
181
|
+
- Every code fence has a language specifier (` ```bash `, ` ```json `, ` ```yaml `, ` ```typescript `).
|
|
182
|
+
- `webServer.port` in commands matches the actual value from `config/default.yaml`.
|
|
183
|
+
- Custom header names in Client Integration snippets match what the server actually reads.
|
|
184
|
+
- Relative links for internal references: `[…](./readme-docs/authentication.md)`.
|
|
185
|
+
- Line length ≤ 120 chars where practical. Exceptions: URLs, code blocks, tables.
|
|
186
|
+
- No marketing superlatives. Active voice. Short paragraphs (2–4 sentences).
|
|
187
|
+
|
|
188
|
+
See `reference/templates.md` for canonical blocks.
|
|
189
|
+
|
|
190
|
+
### Step 5 — Generate satellite `readme-docs/*.md` files
|
|
191
|
+
|
|
192
|
+
For each finding classified as *satellite* in Step 2, create a Markdown file under `readme-docs/` (create
|
|
193
|
+
the folder if missing). Use `reference/satellite-templates.md` as a starting point — skeletons are
|
|
194
|
+
provided for common topics (authentication, testing, webhooks, consul, active-directory, database,
|
|
195
|
+
configuration). **Adapt every skeleton to actual values from the project.**
|
|
196
|
+
|
|
197
|
+
For project-specific capabilities (fuzzy resolution, custom endpoints, etc.) compose a new
|
|
198
|
+
`readme-docs/<kebab-name>.md` with sections: *Overview*, *How it works*, *Configuration*, *Examples*.
|
|
199
|
+
|
|
200
|
+
Every satellite MD begins with a 1-sentence summary so it stands alone when opened directly.
|
|
201
|
+
|
|
202
|
+
### Step 6 — Update `SKILL_README.md`
|
|
203
|
+
|
|
204
|
+
If `.claude/skills/` is non-empty, regenerate `SKILL_README.md` in the repository root. Keep the
|
|
205
|
+
existing format (seen in mcp-jira / mcp-wiki): per-skill sections with command, launch mode,
|
|
206
|
+
arguments table, examples. **Do not move this file into `readme-docs/`** — the projects' convention keeps
|
|
207
|
+
it at the root.
|
|
208
|
+
|
|
209
|
+
### Step 7 — Validate
|
|
210
|
+
|
|
211
|
+
Run through this checklist before declaring done:
|
|
212
|
+
|
|
213
|
+
- [ ] Canonical section order followed; no empty headings
|
|
214
|
+
- [ ] Every section in the main README is ≤ ~40 lines, or split into a satellite
|
|
215
|
+
- [ ] Tool count in the `## Tools (<count>)` heading matches the table
|
|
216
|
+
- [ ] Every satellite link resolves to an existing file in `readme-docs/`
|
|
217
|
+
- [ ] No satellite file for a disabled feature
|
|
218
|
+
- [ ] `webServer.port` in all commands matches `config/default.yaml`
|
|
219
|
+
- [ ] Custom header names in Client Integration match those the server parses
|
|
220
|
+
- [ ] JSON snippets are valid JSON; YAML snippets are valid YAML
|
|
221
|
+
- [ ] Every code fence has a language tag
|
|
222
|
+
- [ ] Relative links use `./readme-docs/...` form
|
|
223
|
+
- [ ] Line length ≤ 120 chars outside URLs / code / tables
|
|
224
|
+
- [ ] Previous README backed up to `README.backup.md` when rewriting
|
|
225
|
+
|
|
226
|
+
## Output
|
|
227
|
+
|
|
228
|
+
1. `README.md` — restructured per canonical order
|
|
229
|
+
2. `readme-docs/<topic>.md` — one per satellite topic, only those the project needs
|
|
230
|
+
3. `SKILL_README.md` — regenerated if `.claude/skills/` is present
|
|
231
|
+
4. `README.backup.md` — backup of previous README when rewriting
|
|
232
|
+
|
|
233
|
+
## References
|
|
234
|
+
|
|
235
|
+
- `reference/templates.md` — canonical section blocks for the main README
|
|
236
|
+
- `reference/satellite-templates.md` — skeletons for common `readme-docs/*.md` files
|
|
237
|
+
- `reference/best-practices.md` — writing style and formatting guidelines
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
# Documentation Best Practices
|
|
2
|
+
|
|
3
|
+
## Writing Style
|
|
4
|
+
|
|
5
|
+
### Be Clear and Concise
|
|
6
|
+
|
|
7
|
+
**Good:**
|
|
8
|
+
> Install the package using npm.
|
|
9
|
+
|
|
10
|
+
**Bad:**
|
|
11
|
+
> You can install this package by utilizing the npm package manager which is included with Node.js.
|
|
12
|
+
|
|
13
|
+
### Use Active Voice
|
|
14
|
+
|
|
15
|
+
**Good:**
|
|
16
|
+
> The function returns a promise.
|
|
17
|
+
|
|
18
|
+
**Bad:**
|
|
19
|
+
> A promise is returned by the function.
|
|
20
|
+
|
|
21
|
+
### Write for Your Audience
|
|
22
|
+
|
|
23
|
+
- **Developers**: Include technical details, API references
|
|
24
|
+
- **End Users**: Focus on features, benefits, screenshots
|
|
25
|
+
- **Contributors**: Explain architecture, setup, testing
|
|
26
|
+
|
|
27
|
+
## Structure
|
|
28
|
+
|
|
29
|
+
### Start with the Most Important Information
|
|
30
|
+
|
|
31
|
+
1. What is it?
|
|
32
|
+
2. Why should I use it?
|
|
33
|
+
3. How do I get started?
|
|
34
|
+
|
|
35
|
+
### Use Headings Effectively
|
|
36
|
+
|
|
37
|
+
```markdown
|
|
38
|
+
# Main Title (H1) - Only one per document
|
|
39
|
+
|
|
40
|
+
## Major Sections (H2)
|
|
41
|
+
|
|
42
|
+
### Subsections (H3)
|
|
43
|
+
|
|
44
|
+
#### Details (H4) - Use sparingly
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Keep Paragraphs Short
|
|
48
|
+
|
|
49
|
+
- 2-4 sentences per paragraph
|
|
50
|
+
- One idea per paragraph
|
|
51
|
+
- Use bullet points for lists
|
|
52
|
+
|
|
53
|
+
## Code Examples
|
|
54
|
+
|
|
55
|
+
### Make Examples Runnable
|
|
56
|
+
|
|
57
|
+
**Good:**
|
|
58
|
+
```javascript
|
|
59
|
+
const api = require('my-api');
|
|
60
|
+
api.connect('https://api.example.com');
|
|
61
|
+
const users = await api.getUsers();
|
|
62
|
+
console.log(users);
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
**Bad:**
|
|
66
|
+
```javascript
|
|
67
|
+
// Connect to API
|
|
68
|
+
api.connect(url);
|
|
69
|
+
// Get users
|
|
70
|
+
getUsers();
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Show Expected Output
|
|
74
|
+
|
|
75
|
+
```javascript
|
|
76
|
+
const result = add(2, 3);
|
|
77
|
+
console.log(result);
|
|
78
|
+
// Output: 5
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Include Error Handling
|
|
82
|
+
|
|
83
|
+
```javascript
|
|
84
|
+
try {
|
|
85
|
+
const data = await fetchData();
|
|
86
|
+
} catch (error) {
|
|
87
|
+
console.error('Failed to fetch:', error.message);
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Formatting
|
|
92
|
+
|
|
93
|
+
### Use Consistent Terminology
|
|
94
|
+
|
|
95
|
+
Pick one term and stick with it:
|
|
96
|
+
- "function" not "function/method/procedure"
|
|
97
|
+
- "parameter" not "parameter/argument/input"
|
|
98
|
+
|
|
99
|
+
### Format Code Inline
|
|
100
|
+
|
|
101
|
+
Use backticks for:
|
|
102
|
+
- Function names: `getData()`
|
|
103
|
+
- Variables: `userId`
|
|
104
|
+
- File names: `config.json`
|
|
105
|
+
- Commands: `npm install`
|
|
106
|
+
|
|
107
|
+
### Use Tables for Comparisons
|
|
108
|
+
|
|
109
|
+
| Feature | Option A | Option B |
|
|
110
|
+
|---------|----------|----------|
|
|
111
|
+
| Speed | Fast | Slow |
|
|
112
|
+
| Memory | Low | High |
|
|
113
|
+
|
|
114
|
+
## Common Sections
|
|
115
|
+
|
|
116
|
+
### Installation
|
|
117
|
+
|
|
118
|
+
Always include:
|
|
119
|
+
- Prerequisites (if any)
|
|
120
|
+
- Installation command
|
|
121
|
+
- Verification step
|
|
122
|
+
|
|
123
|
+
```markdown
|
|
124
|
+
## Installation
|
|
125
|
+
|
|
126
|
+
**Prerequisites:** Node.js 18+
|
|
127
|
+
|
|
128
|
+
\`\`\`bash
|
|
129
|
+
npm install package-name
|
|
130
|
+
\`\`\`
|
|
131
|
+
|
|
132
|
+
Verify installation:
|
|
133
|
+
\`\`\`bash
|
|
134
|
+
package-name --version
|
|
135
|
+
\`\`\`
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Configuration
|
|
139
|
+
|
|
140
|
+
Show default values:
|
|
141
|
+
|
|
142
|
+
```markdown
|
|
143
|
+
## Configuration
|
|
144
|
+
|
|
145
|
+
\`\`\`json
|
|
146
|
+
{
|
|
147
|
+
"timeout": 5000, // Default: 5000ms
|
|
148
|
+
"retries": 3, // Default: 3
|
|
149
|
+
"debug": false // Default: false
|
|
150
|
+
}
|
|
151
|
+
\`\`\`
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Troubleshooting
|
|
155
|
+
|
|
156
|
+
Address common issues:
|
|
157
|
+
|
|
158
|
+
```markdown
|
|
159
|
+
## Troubleshooting
|
|
160
|
+
|
|
161
|
+
### Error: "Module not found"
|
|
162
|
+
|
|
163
|
+
**Cause:** Package not installed
|
|
164
|
+
|
|
165
|
+
**Solution:**
|
|
166
|
+
\`\`\`bash
|
|
167
|
+
npm install missing-package
|
|
168
|
+
\`\`\`
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## Maintenance
|
|
172
|
+
|
|
173
|
+
### Keep Documentation Updated
|
|
174
|
+
|
|
175
|
+
- Update docs with code changes
|
|
176
|
+
- Review docs during code review
|
|
177
|
+
- Mark deprecated features clearly
|
|
178
|
+
|
|
179
|
+
### Version Documentation
|
|
180
|
+
|
|
181
|
+
```markdown
|
|
182
|
+
## Version 2.0.0 (Breaking Changes)
|
|
183
|
+
|
|
184
|
+
- Removed: `oldFunction()`
|
|
185
|
+
- Changed: `newFunction()` now returns Promise
|
|
186
|
+
- Added: `anotherFunction()`
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Link to External Resources
|
|
190
|
+
|
|
191
|
+
```markdown
|
|
192
|
+
For more information, see:
|
|
193
|
+
- [Official Docs](https://example.com/docs)
|
|
194
|
+
- [API Reference](https://example.com/api)
|
|
195
|
+
- [Tutorial](https://example.com/tutorial)
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
## Accessibility
|
|
199
|
+
|
|
200
|
+
### Use Descriptive Link Text
|
|
201
|
+
|
|
202
|
+
**Good:**
|
|
203
|
+
> See the [installation guide](link) for details.
|
|
204
|
+
|
|
205
|
+
**Bad:**
|
|
206
|
+
> Click [here](link) for more information.
|
|
207
|
+
|
|
208
|
+
### Provide Alt Text for Images
|
|
209
|
+
|
|
210
|
+
```markdown
|
|
211
|
+

|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### Use Semantic Markdown
|
|
215
|
+
|
|
216
|
+
- Use proper heading hierarchy
|
|
217
|
+
- Use lists for lists
|
|
218
|
+
- Use code blocks for code
|