Skip to content

Commit 42c3cc1

Browse files
committed
fix: improve skill file
1 parent 4ee733e commit 42c3cc1

1 file changed

Lines changed: 80 additions & 2 deletions

File tree

  • skills/nodejs-cli-best-practices

skills/nodejs-cli-best-practices/SKILL.md

Lines changed: 80 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
---
22
name: nodejs-cli-best-practices
3-
description: Guide and audit Node.js CLI application development against 37 established best practices covering UX, distribution, interoperability, accessibility, testing, error handling, development setup, analytics, versioning, and security. Use this skill whenever building, extending, reviewing, or scaffolding a Node.js command-line tool — including when adding commands, flags, argument parsing, error handling, color output, STDIN support, configuration precedence, exit codes, --version flags, npm distribution, or any other CLI feature. If someone is working on Node.js CLI code, this skill applies even if they don't explicitly ask about best practices. Also trigger when someone asks "how should I implement X in my CLI" or "what's the right way to do Y in a Node.js CLI".
3+
description: Guide and audit Node.js CLI application development against 37 established best practices covering UX, distribution, interoperability, accessibility, testing, error handling, development setup, analytics, versioning, and security. Use this skill when building, extending, reviewing, or scaffolding a Node.js CLI — including when someone says "audit my CLI", "review my CLI code", "I'm building a CLI tool", or asks about adding argument parsing, error handling, color output, STDIN, --json flags, exit codes, --version flags, or npm publishing. Applies even when best practices are not explicitly mentioned. Also trigger for "how should I implement X in my CLI" or "what's the right way to do Y in a Node.js CLI". Do NOT use for Node.js backend or API development with no CLI entry point.
4+
metadata:
5+
version: 1.0.0
6+
category: nodejs
7+
tags: [nodejs, cli, best-practices, audit, command-line]
48
---
59

610
This skill operates in two modes — **audit** for reviewing existing CLI code and **development guide** for building new features or tools.
711

8-
Read `references/best-practices.md` for the complete reference of all 37 practices, including code examples and recommended packages. Use it as your source of truth in both modes.
12+
## Critical
13+
14+
Always read `references/best-practices.md` before producing any output. It contains the complete reference for all 37 practices with code examples and recommended packages. It is the source of truth for both modes — do not rely on general knowledge alone, as several practices (specific package recommendations, §X.X numbering, configuration precedence order) are specific to this guide.
915

1016
## Determining the mode
1117

@@ -120,3 +126,75 @@ When building a new CLI feature or tool, don't wait to be asked — surface rele
120126
| Configuration persistence | §1.3, §2.3 |
121127
| Node.js version targeting | §4.3 |
122128
| Analytics / telemetry | §8.1 |
129+
130+
---
131+
132+
## Examples
133+
134+
### Example 1: Audit mode
135+
136+
**User says:** "Audit my Node.js CLI against best practices. Here's my entry file and package.json."
137+
138+
**Actions:**
139+
1. Read `references/best-practices.md`
140+
2. Examine the provided files against each applicable practice
141+
3. Produce the structured audit report with per-section table and priority recommendations
142+
143+
**Expected output shape:**
144+
```
145+
## Node.js CLI Best Practices Audit
146+
### Summary
147+
✅ 3 practices followed ❌ 12 not implemented ⚠️ 2 need attention ➖ 20 not applicable
148+
### 1. Command Line Experience
149+
| # | Practice | Status | Finding |
150+
...
151+
### Priority recommendations
152+
**High priority** (user-facing or CI-breaking): ...
153+
```
154+
155+
---
156+
157+
### Example 2: Development guide mode (new CLI from scratch)
158+
159+
**User says:** "I'm building a Node.js CLI that parses log files and outputs a summary table. It needs to work cross-platform and I want to publish it on npm."
160+
161+
**Actions:**
162+
1. Read `references/best-practices.md`
163+
2. Identify all practices relevant to this CLI type (cross-platform, npm-published, table output)
164+
3. Organize guidance by development phase (project setup → argument design → I/O → errors → UX → versioning → security)
165+
166+
**Expected output shape:**
167+
```
168+
## Node.js CLI best practices for [log-parser]
169+
### Checklist
170+
- [ ] §7.1 bin object in package.json
171+
- [ ] §4.4 Shebang: #!/usr/bin/env node
172+
...
173+
### Implementation
174+
[concrete, copy-pasteable code per phase]
175+
### Recommended packages
176+
- `commander` — argument parsing ...
177+
```
178+
179+
---
180+
181+
### Example 3: Development guide mode (targeted feature)
182+
183+
**User says:** "My CLI is crashing and just dumping stack traces. How do I add proper error handling?"
184+
185+
**Actions:**
186+
1. Read `references/best-practices.md` sections §6.1–§6.5
187+
2. Surface only the directly relevant practices
188+
3. Provide a concrete, copy-pasteable error handling wrapper
189+
190+
---
191+
192+
## Common mistakes to avoid
193+
194+
| Mistake | Why it matters | Correct approach |
195+
|---------|---------------|------------------|
196+
| Marking §4.1 (Docker) as ❌ for a small personal CLI | Docker is rarely needed; not applicable is honest | Use ➖ when the practice genuinely doesn't fit the project's scope |
197+
| Only auditing the entry file, ignoring package.json | Several high-impact violations (§7.1, §7.3, §2.1, §4.3) live in package.json | Always audit both the entry file and package.json when both are provided |
198+
| Recommending `package-lock.json` for §2.2 | The practice specifically calls for `npm-shrinkwrap.json` for published CLIs | Reference `references/best-practices.md` for the exact requirement |
199+
| Skipping the priority grouping in audit reports | Users need to know what to fix first, not just what's wrong | Always include High / Medium / Low priority sections with concrete fixes |
200+
| Providing a development guide without code examples | Prose guidance alone is not actionable | Every recommended practice should include at least one copy-pasteable code block |

0 commit comments

Comments
 (0)