feat(docs): init cli - #422
Conversation
WalkthroughAdds a CLI bootstrap script and package metadata to packages/docs that detects Claude/Cursor tooling, creates a Claude skill and Cursor rules (symlink or copy), updates or creates CLAUDE.md to include Gunshi instructions if missing, and updates the docs setup guide and package.json with new runtime deps and a bin entry. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Dev as Developer
participant CLI as gunshi-docs-init
participant FS as Filesystem
participant Claude as Claude tooling
participant Cursor as Cursor tooling
Dev->>CLI: run init
CLI->>Claude: detect (which claude)
CLI->>Cursor: detect (which cursor / cursor-agent)
CLI->>FS: ensure .claude/skills/use-gunshi-cli/SKILL.md
CLI->>FS: read CLAUDE.md
alt CLAUDE.md lacks Gunshi content
CLI->>FS: update/create CLAUDE.md with Gunshi instructions
else
CLI->>Dev: log already present
end
alt Cursor present
CLI->>FS: Windows? copy skill -> CURSOR_RULES_PATH
CLI->>FS: non-Windows? create relative symlink CURSOR_RULES_PATH -> CLAUDE skill
else
CLI->>Dev: log Cursor not found
end
CLI->>Dev: prompt to install Gunshi / `@gunshi/docs` and run package manager if confirmed
CLI->>Dev: log summary
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
Suggested labels
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
@gunshi/bone
@gunshi/definition
@gunshi/docs
gunshi
@gunshi/plugin
@gunshi/plugin-completion
@gunshi/plugin-dryrun
@gunshi/plugin-global
@gunshi/plugin-i18n
@gunshi/plugin-renderer
@gunshi/resources
@gunshi/shared
commit: |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
packages/docs/bin/init.js (2)
10-15: Consider correcting “Bun API docs” wording in the skill promptThe
USE_GUNSHI_PROMPTstring currently says:For more information, read the Bun API docs in
node_modules/@gunshi/docs/**.md.Given this is advertising Gunshi’s own docs, “Bun API docs” looks like a copy‑paste artifact and may confuse users.
Consider something like:
-For more information, read the Bun API docs in `node_modules/@gunshi/docs/**.md`. +For more information, read the Gunshi docs in `node_modules/@gunshi/docs/**.md`.or similar wording that explicitly mentions Gunshi rather than Bun.
Also applies to: 17-26
77-79: Optional: avoid overwriting an existing SKILL.md on rerunsRight now the script always rewrites
.claude/skills/${SKILL_NAME}/SKILL.mdon every run. That’s fine for a pure bootstrapper, but if users ever tweak the skill locally, running the init script again will silently discard those edits.If you want to be conservative, you could skip creation when the file already exists:
-await fs.mkdir(path.dirname(CLAUDE_SKILL_PATH), { recursive: true }) -await fs.writeFile(CLAUDE_SKILL_PATH, SKILL_CONTENT, 'utf8') -console.log(`Created Claude skill at ${CLAUDE_SKILL_PATH}`) +await fs.mkdir(path.dirname(CLAUDE_SKILL_PATH), { recursive: true }) +if (!(await fileExists(CLAUDE_SKILL_PATH))) { + await fs.writeFile(CLAUDE_SKILL_PATH, SKILL_CONTENT, 'utf8') + console.log(`Created Claude skill at ${CLAUDE_SKILL_PATH}`) +} else { + console.log(`Claude skill already exists at ${CLAUDE_SKILL_PATH}, leaving it unchanged`) +}Not required, but it can make the init script safer to re‑run.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (2)
packages/docs/bin/init.js(1 hunks)packages/docs/package.json(2 hunks)
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: CR
Repo: kazupon/gunshi PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-05T09:55:04.584Z
Learning: Update documentation at gunshi.dev when adding new features or changing APIs
Learnt from: CR
Repo: kazupon/gunshi PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-05T09:55:04.584Z
Learning: Applies to packages/plugin-*/src/**/*.ts : Implement plugins using gunshi/plugin package for minimal dependencies following the plugin API in packages/plugin/src/
Learnt from: CR
Repo: kazupon/gunshi PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-05T09:55:04.584Z
Learning: Applies to packages/gunshi/src/**/*.ts : Test changes across all supported runtimes (Node.js, Deno, Bun) when modifying core functionality
📚 Learning: 2025-12-05T09:55:04.584Z
Learnt from: CR
Repo: kazupon/gunshi PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-05T09:55:04.584Z
Learning: Update documentation at gunshi.dev when adding new features or changing APIs
Applied to files:
packages/docs/package.json
📚 Learning: 2025-12-05T09:55:04.584Z
Learnt from: CR
Repo: kazupon/gunshi PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-05T09:55:04.584Z
Learning: Applies to packages/gunshi/src/**/*.ts : Test changes across all supported runtimes (Node.js, Deno, Bun) when modifying core functionality
Applied to files:
packages/docs/package.json
📚 Learning: 2025-12-05T09:55:04.584Z
Learnt from: CR
Repo: kazupon/gunshi PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-05T09:55:04.584Z
Learning: Applies to packages/plugin-*/src/**/*.ts : Implement plugins using gunshi/plugin package for minimal dependencies following the plugin API in packages/plugin/src/
Applied to files:
packages/docs/package.json
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Test on Node.js 20
🔇 Additional comments (3)
packages/docs/package.json (1)
36-38: CLI bin exposure and publish config look correctThe
binmapping, inclusion ofbininfiles, and the adjusted devDependency wiring are consistent with exposing this CLI viapnpm dlx @gunshi/docsand publishing the script from the docs package. No issues from a packaging perspective.Also, when this is merged, make sure the new CLI usage is documented on gunshi.dev so users can discover
pnpm dlx @gunshi/docsand what it does (flags, behavior, etc.).Based on learnings, please double‑check that the public docs are updated alongside this change.
Also applies to: 39-55, 61-61
packages/docs/bin/init.js (2)
49-59: Helper utilities for CLAUDE.md detection look good
hasGunshiInstructionandfileExistsare small, robust helpers that correctly handle missing files and use simple regex patterns to avoid duplicating Gunshi instructions inCLAUDE.md. The error‑swallowing here is appropriate for a best‑effort setup script.Also applies to: 61-69
39-47: Fixmkdirusage for Windows compatibilityRight now the script shells out to
mkdir -p:
- Line 77:
await x('mkdir', ['-p', path.dirname(CLAUDE_SKILL_PATH)])- Line 106:
await x('mkdir', ['-p', path.dirname(CURSOR_RULES_PATH)])This is POSIX‑specific and will fail on plain Windows shells where there is no
mkdirbinary and-pisn't supported, causing the CLI to crash even though you've otherwise handled Windows (e.g.,isWindows, avoiding symlinks).Replace with Node's fs API, which is cross‑platform and supports recursive directory creation:
-await x('mkdir', ['-p', path.dirname(CLAUDE_SKILL_PATH)]) +await fs.mkdir(path.dirname(CLAUDE_SKILL_PATH), { recursive: true }) await fs.writeFile(CLAUDE_SKILL_PATH, SKILL_CONTENT, 'utf8') - await x('mkdir', ['-p', path.dirname(CURSOR_RULES_PATH)]) + await fs.mkdir(path.dirname(CURSOR_RULES_PATH), { recursive: true })This keeps the behavior the same while making the CLI runnable on Windows (cmd/PowerShell) and Unix‑like shells alike. Note that
whichcalls are safely wrapped incatch, so the hard failure is specifically from themkdirinvocations.
There was a problem hiding this comment.
Actionable comments posted: 3
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/docs/bin/init.js(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: CR
Repo: kazupon/gunshi PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-05T09:55:04.584Z
Learning: Update documentation at gunshi.dev when adding new features or changing APIs
Learnt from: CR
Repo: kazupon/gunshi PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-05T09:55:04.584Z
Learning: Applies to packages/plugin-*/src/**/*.ts : Implement plugins using gunshi/plugin package for minimal dependencies following the plugin API in packages/plugin/src/
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Test on Node.js 20
🔇 Additional comments (2)
packages/docs/bin/init.js (2)
50-59: Verify the package scope pattern.The pattern
/@kazupon\/gunshi/ion line 54 checks for@kazupon/gunshi, but the package appears to be under the@gunshiscope. Determine if this legacy pattern is still needed or should be removed.
10-15: Verify the documentation path referenced in the USE_GUNSHI_PROMPT constant.The path
node_modules/@gunshi/docs/**.mdmay be incorrect when users invoke the CLI viapnpm dlx @gunshi/docs. When packages are installed temporarily throughpnpm dlx, the directory structure and node_modules resolution can differ from standard installations, potentially making the documentation unreachable at the specified path.Confirm the actual location of documentation files and ensure the path resolves correctly during execution.
| const [hasClaudeCode, hasCursor, hasCursorCli] = await Promise.all( | ||
| ['claude', 'cursor', 'cursor-agent'].map(cmd => | ||
| x('which', [cmd], { throwOnError: false }) | ||
| .then(({ stdout }) => stdout.trim().length > 0) | ||
| .catch(() => false) | ||
| ) | ||
| ) |
There was a problem hiding this comment.
Critical: Tool detection fails on Windows.
The which command is Unix-specific and doesn't exist on Windows (Windows uses where instead). This causes tool detection to fail on Windows, preventing Claude/Cursor integration from being set up even when the tools are installed.
Apply this diff to fix cross-platform tool detection:
-const [hasClaudeCode, hasCursor, hasCursorCli] = await Promise.all(
- ['claude', 'cursor', 'cursor-agent'].map(cmd =>
- x('which', [cmd], { throwOnError: false })
- .then(({ stdout }) => stdout.trim().length > 0)
- .catch(() => false)
- )
-)
+const isWindows = process.platform === 'win32'
+const whichCmd = isWindows ? 'where' : 'which'
+
+const [hasClaudeCode, hasCursor, hasCursorCli] = await Promise.all(
+ ['claude', 'cursor', 'cursor-agent'].map(cmd =>
+ x(whichCmd, [cmd], { throwOnError: false })
+ .then(({ stdout }) => stdout.trim().length > 0)
+ .catch(() => false)
+ )
+)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const [hasClaudeCode, hasCursor, hasCursorCli] = await Promise.all( | |
| ['claude', 'cursor', 'cursor-agent'].map(cmd => | |
| x('which', [cmd], { throwOnError: false }) | |
| .then(({ stdout }) => stdout.trim().length > 0) | |
| .catch(() => false) | |
| ) | |
| ) | |
| const isWindows = process.platform === 'win32' | |
| const whichCmd = isWindows ? 'where' : 'which' | |
| const [hasClaudeCode, hasCursor, hasCursorCli] = await Promise.all( | |
| ['claude', 'cursor', 'cursor-agent'].map(cmd => | |
| x(whichCmd, [cmd], { throwOnError: false }) | |
| .then(({ stdout }) => stdout.trim().length > 0) | |
| .catch(() => false) | |
| ) | |
| ) |
🤖 Prompt for AI Agents
In packages/docs/bin/init.js around lines 39 to 45, the current tool detection
uses the Unix-only "which" command so it fails on Windows; change the logic to
pick the platform-appropriate locator command (use "where" when process.platform
=== 'win32', otherwise "which") and run that for each tool, keeping
throwOnError: false; normalize and trim stdout to decide presence, and ensure
catch returns false on error so detection works cross-platform.
| // - Create skill file at .claude/skills/use-gunshi-cli/SKILL.md | ||
| // - Update or create CLAUDE.md with instruction to use the skill | ||
| // (skip if Gunshi is already mentioned to avoid duplication) | ||
| await x('mkdir', ['-p', path.dirname(CLAUDE_SKILL_PATH)]) |
There was a problem hiding this comment.
Critical: Directory creation fails on Windows.
The mkdir -p command is Unix-specific and will fail on Windows. Use Node.js fs.mkdir with { recursive: true } for cross-platform compatibility.
Apply this diff:
-await x('mkdir', ['-p', path.dirname(CLAUDE_SKILL_PATH)])
+await fs.mkdir(path.dirname(CLAUDE_SKILL_PATH), { recursive: true })📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| await x('mkdir', ['-p', path.dirname(CLAUDE_SKILL_PATH)]) | |
| await fs.promises.mkdir(path.dirname(CLAUDE_SKILL_PATH), { recursive: true }) |
🤖 Prompt for AI Agents
In packages/docs/bin/init.js around line 77, the call await x('mkdir', ['-p',
path.dirname(CLAUDE_SKILL_PATH)]) uses a Unix-only shell mkdir; replace it with
Node's fs.mkdir (or fs.promises.mkdir) using path.dirname(CLAUDE_SKILL_PATH) and
the { recursive: true } option for cross-platform compatibility, ensuring you
import/require fs at the top and await the async mkdir call (or use mkdirSync if
keeping sync flow).
| // - On Linux/macOS: create symlink to Claude skill file | ||
| // - On Windows: copy the file (symlinks require admin privileges) | ||
| if (hasCursorEditors) { | ||
| await x('mkdir', ['-p', path.dirname(CURSOR_RULES_PATH)]) |
There was a problem hiding this comment.
Critical: Directory creation fails on Windows.
The mkdir -p command is Unix-specific and will fail on Windows. Use Node.js fs.mkdir with { recursive: true } for cross-platform compatibility.
Apply this diff:
- await x('mkdir', ['-p', path.dirname(CURSOR_RULES_PATH)])
+ await fs.mkdir(path.dirname(CURSOR_RULES_PATH), { recursive: true })Committable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In packages/docs/bin/init.js around line 106, the code calls the Unix-only shell
command `mkdir -p`, which fails on Windows; replace that call with Node's
fs.promises.mkdir (or fs.mkdirSync) using the directory path
(path.dirname(CURSOR_RULES_PATH)) and the option { recursive: true } for
cross-platform directory creation, and ensure fs is imported/required at the top
of the file.
9a4732a to
b914914
Compare
There was a problem hiding this comment.
Actionable comments posted: 0
♻️ Duplicate comments (2)
packages/docs/bin/init.js (2)
39-45: Tool detection is Unix-only; on Windows it always reports tools as missingUsing
whichhere will fail on Windows (which doesn’t ship that command), sohasClaudeCode,hasCursor, andhasCursorCliwill all befalseeven when the tools are installed, and the script will silently skip CLAUDE.md and Cursor setup on Windows.Refactor detection to choose the locator command based on
process.platform, and reuse that for all three tools (and remove the later duplicateisWindowsdefinition):-const [hasClaudeCode, hasCursor, hasCursorCli] = await Promise.all( - ['claude', 'cursor', 'cursor-agent'].map(cmd => - x('which', [cmd], { throwOnError: false }) - .then(({ stdout }) => stdout.trim().length > 0) - .catch(() => false) - ) -) - -const isWindows = process.platform === 'win32' +const isWindows = process.platform === 'win32' +const whichCmd = isWindows ? 'where' : 'which' + +const [hasClaudeCode, hasCursor, hasCursorCli] = await Promise.all( + ['claude', 'cursor', 'cursor-agent'].map(cmd => + x(whichCmd, [cmd], { throwOnError: false }) + .then(({ stdout }) => stdout.trim().length > 0) + .catch(() => false) + ) +)(And delete the old
const isWindows = process.platform === 'win32'further down.)Also applies to: 71-71
77-79: Unix-onlymkdir -pwill fail on Windows; usefs.mkdirwithrecursive: trueBoth directory creations rely on
mkdir -p, which is not available on Windows command shells. This will throw and prevent skill/rules setup on Windows.Since you already import
fsfromnode:fs/promises, switch to the cross‑platform API:-await x('mkdir', ['-p', path.dirname(CLAUDE_SKILL_PATH)]) +await fs.mkdir(path.dirname(CLAUDE_SKILL_PATH), { recursive: true }) @@ - await x('mkdir', ['-p', path.dirname(CURSOR_RULES_PATH)]) + await fs.mkdir(path.dirname(CURSOR_RULES_PATH), { recursive: true })Also applies to: 106-107
🧹 Nitpick comments (1)
packages/docs/bin/init.js (1)
78-79: Consider avoiding silent overwrites of existing Claude/Cursor configRight now rerunning the CLI will always overwrite:
.claude/skills/use-gunshi-cli/SKILL.md.cursor/rules/use-gunshi-cli.mdc(or the symlink target)This can clobber user-customized instructions or locally tweaked rules.
Consider checking for existing files and either skipping or clearly logging that you are overwriting them. For example, for the Claude skill:
-await fs.writeFile(CLAUDE_SKILL_PATH, SKILL_CONTENT, 'utf8') -console.log(`Created Claude skill at ${CLAUDE_SKILL_PATH}`) +const skillExists = await fileExists(CLAUDE_SKILL_PATH) +if (!skillExists) { + await fs.writeFile(CLAUDE_SKILL_PATH, SKILL_CONTENT, 'utf8') + console.log(`Created Claude skill at ${CLAUDE_SKILL_PATH}`) +} else { + console.log(`Claude skill already exists at ${CLAUDE_SKILL_PATH}, leaving as-is`) +}You can apply a similar pattern for the Cursor rules path if you want to preserve local edits rather than always replacing them.
Also applies to: 110-111, 116-118
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (2)
packages/docs/bin/init.js(1 hunks)packages/docs/package.json(2 hunks)
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: CR
Repo: kazupon/gunshi PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-05T09:55:04.584Z
Learning: Update documentation at gunshi.dev when adding new features or changing APIs
📚 Learning: 2025-12-05T09:55:04.584Z
Learnt from: CR
Repo: kazupon/gunshi PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-05T09:55:04.584Z
Learning: Update documentation at gunshi.dev when adding new features or changing APIs
Applied to files:
packages/docs/package.json
📚 Learning: 2025-12-05T09:55:04.584Z
Learnt from: CR
Repo: kazupon/gunshi PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-05T09:55:04.584Z
Learning: Applies to packages/gunshi/src/**/*.ts : Test changes across all supported runtimes (Node.js, Deno, Bun) when modifying core functionality
Applied to files:
packages/docs/package.json
📚 Learning: 2025-12-05T09:55:04.584Z
Learnt from: CR
Repo: kazupon/gunshi PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-05T09:55:04.584Z
Learning: Applies to packages/plugin-*/src/**/*.ts : Implement plugins using gunshi/plugin package for minimal dependencies following the plugin API in packages/plugin/src/
Applied to files:
packages/docs/package.json
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Test on Node.js 20
🔇 Additional comments (2)
packages/docs/package.json (2)
36-55: CLI bin wiring and packaging look consistentThe new
binentry and inclusion ofbininfiles, along with a dedicated runtime deps block, are coherent with exposing this package as a CLI. Nothing blocking from a manifest perspective; please just verifypnpm dlx @gunshi/docsresolves and runs the CLI as expected, and ensure the new command is documented for users (e.g., on gunshi.dev). Based on learnings, remember to update the gunshi.dev docs for this new CLI entrypoint.
61-61: Dev dependency adjustment is purely organizationalThe change in the devDependencies block appears to be ordering/formatting only and should not affect behavior.
kazupon
left a comment
There was a problem hiding this comment.
Wow!
This is amazing PR!
I added it to docs a little while ago.
I hope that you should be replaced with the content from your PR. 🙏
https://github.com/kazupon/gunshi/blob/main/packages/docs/src/guide/introduction/setup.md#llm-assisted-development
|
thanks, so we need to add description to readme? |
|
No additions are needed to the readme. We should update only the docs at the above URL, because that section is read by user at gunshi.dev |
Changed the init CLI to install packages with appropriate dependency types: - gunshi: installed as production dependency (dev: false) since it is required at runtime for CLI applications - @gunshi/docs: installed as dev dependency (dev: true) since it is only needed for LLM-assisted development Also updated the manual installation instructions to reflect this separation, showing two separate npm commands for each package type.
Add documentation for integrating Gunshi with AI coding assistants such as Claude Code and Cursor. The section includes: - Automatic Setup (Recommended): CLI commands to quickly configure Claude Code skills and Cursor rules using @gunshi/docs@beta - Manual Setup: Instructions for manually installing the docs package and configuring AI agent configuration files (CLAUDE.md, .cursor/rules) with reference to the llms.txt format documentation This helps developers leverage AI-assisted development when building CLI applications with Gunshi.
|
@kazupon oh sorry i did some work on it actually.. |
There was a problem hiding this comment.
Actionable comments posted: 0
♻️ Duplicate comments (3)
packages/docs/bin/init.js (3)
41-47: Critical: Tool detection usingwhichstill fails on Windows.The
isWindowsvariable was added at line 73 but isn't used here. Thewhichcommand doesn't exist on Windows.Apply this diff to fix cross-platform tool detection:
+const isWindows = process.platform === 'win32' +const whichCmd = isWindows ? 'where' : 'which' + const [hasClaudeCode, hasCursor, hasCursorCli] = await Promise.all( ['claude', 'cursor', 'cursor-agent'].map(cmd => - x('which', [cmd], { throwOnError: false }) + x(whichCmd, [cmd], { throwOnError: false }) .then(({ stdout }) => stdout.trim().length > 0) .catch(() => false) ) )Then move line 73's
isWindowsdeclaration before this block.
79-79: Critical: Directory creation usingmkdir -pstill fails on Windows.The
isWindowsdetection exists but this line still uses the Unix-only shell command.Apply this diff:
-await x('mkdir', ['-p', path.dirname(CLAUDE_SKILL_PATH)]) +await fs.mkdir(path.dirname(CLAUDE_SKILL_PATH), { recursive: true })
108-108: Critical: Directory creation usingmkdir -pstill fails on Windows.Same issue as line 79.
Apply this diff:
- await x('mkdir', ['-p', path.dirname(CURSOR_RULES_PATH)]) + await fs.mkdir(path.dirname(CURSOR_RULES_PATH), { recursive: true })
🧹 Nitpick comments (1)
packages/docs/bin/init.js (1)
124-138: Consider handling non-interactive environments.When stdin is not a TTY (e.g., piped input in CI),
readline.questionmay hang indefinitely or behave unexpectedly.Consider adding a check for interactive mode:
+// Skip interactive prompt in non-TTY environments +if (!process.stdin.isTTY) { + console.log('\nNon-interactive environment detected. Skipping package installation prompt.') + console.log('You can install manually with:') + console.log(' npm install gunshi') + console.log(' npm install -D @gunshi/docs') + process.exit(0) +} + const rl = readline.createInterface({ input: process.stdin, output: process.stdout })
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (3)
packages/docs/bin/init.js(1 hunks)packages/docs/package.json(2 hunks)packages/docs/src/guide/introduction/setup.md(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/docs/package.json
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: CR
Repo: kazupon/gunshi PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-05T09:55:04.584Z
Learning: Update documentation at gunshi.dev when adding new features or changing APIs
Learnt from: CR
Repo: kazupon/gunshi PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-05T09:55:04.584Z
Learning: Applies to packages/gunshi/src/**/*.ts : Test changes across all supported runtimes (Node.js, Deno, Bun) when modifying core functionality
📚 Learning: 2025-12-05T09:55:04.584Z
Learnt from: CR
Repo: kazupon/gunshi PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-05T09:55:04.584Z
Learning: Update documentation at gunshi.dev when adding new features or changing APIs
Applied to files:
packages/docs/src/guide/introduction/setup.md
🔇 Additional comments (9)
packages/docs/src/guide/introduction/setup.md (2)
61-93: Documentation looks well-structured and aligns with the CLI implementation.The automatic setup section correctly documents the CLI usage and explains what gets configured (Claude Code skills and Cursor rules). The code blocks cover all major package managers.
94-132: Manual setup section provides good fallback instructions.The collapsible details section keeps the documentation clean while providing complete manual configuration guidance for users who prefer it. The markdown snippet for AI agent configuration matches the
USE_GUNSHI_PROMPTconstant ininit.js.packages/docs/bin/init.js (7)
1-9: Imports and shebang look correct.The script properly uses Node.js built-in modules with the
node:prefix and imports the required external dependencies.
10-39: Constants and path definitions are well-organized.The skill content template and paths are clearly defined. Minor note: the globs pattern on line 23 uses spaces after commas (
"*.ts, *.tsx, *.js, *.jsx, package.json"), verify this format is supported by Claude skills.
52-61: Helper function handles errors gracefully.The
hasGunshiInstructionfunction properly catches file read errors and returnsfalse, preventing crashes when checking non-existent files.
63-71: LGTM on thefileExistshelper.Using
fs.accessis an appropriate way to check file existence asynchronously.
83-102: Claude Code setup logic is well-implemented.The code correctly:
- Checks if CLAUDE.md exists before reading
- Avoids duplicate instructions by checking for existing Gunshi mentions
- Handles both append and create scenarios with appropriate logging
110-122: Cursor setup handles Windows correctly for file operations.The Windows vs Unix branching for symlink vs copy is a good approach since symlinks require admin privileges on Windows. The relative symlink calculation is correct.
140-157: Installation flow handles success and failure appropriately.The code correctly separates
gunshias a production dependency and@gunshi/docsas a dev dependency. Error handling withprocess.exit(1)ensures proper exit codes.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/docs/src/guide/introduction/setup.md (1)
94-129: Clarify manual setup file placement.Line 120 mentions placing configuration in both
CLAUDE.mdand.cursor/rules/use-gunshi-cli.md, but the code block (lines 122–129) provides a single markdown snippet. This could be ambiguous for users. Consider:
- Splitting the code block into two separate examples (one for CLAUDE.md, one for .cursor rules)
- Adding explicit instructions about file paths and syntax requirements
- Noting whether this content is auto-generated by the CLI or requires manual addition
-Then add the following to your AI agent's configuration file (e.g., `CLAUDE.md` and `.cursor/rules/use-gunshi-cli.md`): +**For Claude Code**, add the following to `CLAUDE.md`: -```md +```md # CLI Development with Gunshi Use the Gunshi library for creating CLI applications instead of other libraries such as cac, yargs, commander, etc. @@ -128,6 +128,18 @@ For more information, refer to the Gunshi API documentation in `node_modules/@gunshi/docs/**.md`.
+For Cursor, add the following to
.cursor/rules/use-gunshi-cli.md:
+
+md +# CLI Development with Gunshi + +Use the Gunshi library for creating CLI applications instead of other libraries such as cac, yargs, commander, etc. +Gunshi is a modern JavaScript command-line library. + +For more information, refer to the Gunshi API documentation in `node_modules/@gunshi/docs/**.md`. +</blockquote></details> </blockquote></details> <details> <summary>📜 Review details</summary> **Configuration used**: CodeRabbit UI **Review profile**: CHILL **Plan**: Pro <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 8dda32d913a2b2ca7e3e1b8c75f85460d2571588 and 4c44f0077845fc940b68bbe59d1f59132e05510a. </details> <details> <summary>📒 Files selected for processing (1)</summary> * `packages/docs/src/guide/introduction/setup.md` (1 hunks) </details> <details> <summary>🧰 Additional context used</summary> <details> <summary>🧠 Learnings (2)</summary> <details> <summary>📓 Common learnings</summary>Learnt from: CR
Repo: kazupon/gunshi PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-05T09:55:04.584Z
Learning: Update documentation at gunshi.dev when adding new features or changing APIs</details> <details> <summary>📚 Learning: 2025-12-05T09:55:04.584Z</summary>Learnt from: CR
Repo: kazupon/gunshi PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-05T09:55:04.584Z
Learning: Update documentation at gunshi.dev when adding new features or changing APIs**Applied to files:** - `packages/docs/src/guide/introduction/setup.md` </details> </details> </details> <details> <summary>⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)</summary> * GitHub Check: Test on Node.js 20 </details> <details> <summary>🔇 Additional comments (3)</summary><blockquote> <details> <summary>packages/docs/src/guide/introduction/setup.md (3)</summary><blockquote> `61-93`: **Excellent restructuring of setup documentation.** The reorganization clearly prioritizes the recommended automatic CLI setup followed by manual alternatives. The instructions are concise and the feature description (Claude skills and Cursor rules) directly aligns with the PR objectives. The consistency across package managers (npm, pnpm, yarn, bun) is well-maintained. --- `72-85`: **Clarify @beta versioning in CLI instructions.** The CLI commands in lines 72-85 reference `@gunshi/docs@beta`. Confirm whether: 1. The package is published with the `@beta` tag, or if the documentation should reference the stable version 2. These instructions will be updated before merge if `@beta` is temporary 3. The PR objectives align with this versioning choice If `@beta` is intentional for pre-release testing, consider adding a note explaining this is temporary. --- `118-120`: **No changes needed—external reference is accurate.** The URL llmstxt.org correctly references the official llms.txt format specification. The format (Markdown-based site manifest for LLMs) aligns with how the package delivers guide content and API references as markdown files. </blockquote></details> </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
kazupon
left a comment
There was a problem hiding this comment.
@ryoppippi
Great works!
I'll merge your PR!
Thank you!
introduce new cli command for docs.
user just run:
then this cli creates specific claude skills and cursor rules automatically
Summary by CodeRabbit
New Features
Documentation
✏️ Tip: You can customize this high-level summary in your review settings.