Skip to content

feat(docs): init cli - #422

Merged
kazupon merged 7 commits into
kazupon:mainfrom
ryoppippi:docs-init-cli
Dec 6, 2025
Merged

kazupon merged 7 commits into
kazupon:mainfrom
ryoppippi:docs-init-cli

Conversation

@ryoppippi

@ryoppippi ryoppippi commented Dec 6, 2025

Copy link
Copy Markdown
Contributor

introduce new cli command for docs.
user just run:

pnpm dlx @gunshi/docs

then this cli creates specific claude skills and cursor rules automatically

Summary by CodeRabbit

  • New Features

    • Adds a docs CLI to automate integration with Claude, Gunshi and Cursor: detects available tools, creates or updates integration files, handles platform-specific setup, and prompts to install recommended packages.
  • Documentation

    • Reworks setup guidance into an "LLM-Assisted Development" section with Automatic and Manual setup workflows and CLI usage examples.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Dec 6, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Adds 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

Cohort / File(s) Summary
CLI bootstrap script
packages/docs/bin/init.js
New Node.js CLI that detects claude, cursor, and cursor-agent; ensures .claude/skills/use-gunshi-cli/SKILL.md; updates or creates CLAUDE.md avoiding duplicate Gunshi mentions; sets up Cursor rules (relative symlink on non‑Windows; copy on Windows); prompts/installs Gunshi packages.
Package metadata
packages/docs/package.json
Added bin entry gunshi-docs-init./bin/init.js, included bin in published files, and added runtime dependencies tinyexec ^1.0.2 and @antfu/install-pkg ^1.1.0.
Documentation update
packages/docs/src/guide/introduction/setup.md
Replaced "Requirements" with "LLM‑Assisted Development"; added Automatic and Manual setup workflows, multi‑package‑manager install/run snippets (beta tags), and guidance for integrating Claude/Cursor/Gunshi.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Inspect cross-platform symlink vs copy logic and path normalization in packages/docs/bin/init.js
  • Verify deduplication logic when updating CLAUDE.md
  • Confirm safe parent-directory creation and relative symlink correctness
  • Check packages/docs/package.json additions (bin, files, new deps) for packaging implications

Possibly related PRs

Suggested labels

documentation

Poem

🐰 I hopped through code with tiny paws,
I stitched a skill and fixed the cause.
Claude and Cursor wake and play,
A little init brightened the day. 🥕✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(docs): init cli' directly refers to the main change: a new CLI initialization command for the docs package, matching the PR's primary objective.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new

pkg-pr-new Bot commented Dec 6, 2025

Copy link
Copy Markdown

Open in StackBlitz

@gunshi/bone

npm i https://pkg.pr.new/@gunshi/bone@422

@gunshi/definition

npm i https://pkg.pr.new/@gunshi/definition@422

@gunshi/docs

npm i https://pkg.pr.new/@gunshi/docs@422

gunshi

npm i https://pkg.pr.new/gunshi@422

@gunshi/plugin

npm i https://pkg.pr.new/@gunshi/plugin@422

@gunshi/plugin-completion

npm i https://pkg.pr.new/@gunshi/plugin-completion@422

@gunshi/plugin-dryrun

npm i https://pkg.pr.new/@gunshi/plugin-dryrun@422

@gunshi/plugin-global

npm i https://pkg.pr.new/@gunshi/plugin-global@422

@gunshi/plugin-i18n

npm i https://pkg.pr.new/@gunshi/plugin-i18n@422

@gunshi/plugin-renderer

npm i https://pkg.pr.new/@gunshi/plugin-renderer@422

@gunshi/resources

npm i https://pkg.pr.new/@gunshi/resources@422

@gunshi/shared

npm i https://pkg.pr.new/@gunshi/shared@422

commit: 4c44f00

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
packages/docs/bin/init.js (2)

10-15: Consider correcting “Bun API docs” wording in the skill prompt

The USE_GUNSHI_PROMPT string 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 reruns

Right now the script always rewrites .claude/skills/${SKILL_NAME}/SKILL.md on 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

📥 Commits

Reviewing files that changed from the base of the PR and between fbb749a and 19b9d6f.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is 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 correct

The bin mapping, inclusion of bin in files, and the adjusted devDependency wiring are consistent with exposing this CLI via pnpm dlx @gunshi/docs and 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/docs and 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

hasGunshiInstruction and fileExists are small, robust helpers that correctly handle missing files and use simple regex patterns to avoid duplicating Gunshi instructions in CLAUDE.md. The error‑swallowing here is appropriate for a best‑effort setup script.

Also applies to: 61-69


39-47: Fix mkdir usage for Windows compatibility

Right 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 mkdir binary and -p isn'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 which calls are safely wrapped in catch, so the hard failure is specifically from the mkdir invocations.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 19b9d6f and 9a4732a.

📒 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/i on line 54 checks for @kazupon/gunshi, but the package appears to be under the @gunshi scope. 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/**.md may be incorrect when users invoke the CLI via pnpm dlx @gunshi/docs. When packages are installed temporarily through pnpm 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.

Comment thread packages/docs/bin/init.js
Comment on lines +39 to +45
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)
)
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

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.

Suggested change
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.

Comment thread packages/docs/bin/init.js
// - 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)])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

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.

Suggested change
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).

Comment thread packages/docs/bin/init.js
// - 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)])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 missing

Using which here will fail on Windows (which doesn’t ship that command), so hasClaudeCode, hasCursor, and hasCursorCli will all be false even 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 duplicate isWindows definition):

-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-only mkdir -p will fail on Windows; use fs.mkdir with recursive: true

Both 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 fs from node: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 config

Right 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

📥 Commits

Reviewing files that changed from the base of the PR and between 9a4732a and b914914.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is 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 consistent

The new bin entry and inclusion of bin in files, along with a dedicated runtime deps block, are coherent with exposing this package as a CLI. Nothing blocking from a manifest perspective; please just verify pnpm dlx @gunshi/docs resolves 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 organizational

The change in the devDependencies block appears to be ordering/formatting only and should not affect behavior.

@kazupon kazupon left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@ryoppippi

Copy link
Copy Markdown
Contributor Author

thanks, so we need to add description to readme?

@kazupon

kazupon commented Dec 6, 2025

Copy link
Copy Markdown
Owner

No additions are needed to the readme.

https://github.com/kazupon/gunshi/blob/main/packages/docs/src/guide/introduction/setup.md#llm-assisted-development

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.
@ryoppippi
ryoppippi requested a review from kazupon December 6, 2025 15:53
@ryoppippi

ryoppippi commented Dec 6, 2025

Copy link
Copy Markdown
Contributor Author

@kazupon oh sorry i did some work on it actually..
if we need something in addition lmk, or plase fix it whatever you want

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (3)
packages/docs/bin/init.js (3)

41-47: Critical: Tool detection using which still fails on Windows.

The isWindows variable was added at line 73 but isn't used here. The which command 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 isWindows declaration before this block.


79-79: Critical: Directory creation using mkdir -p still fails on Windows.

The isWindows detection 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 using mkdir -p still 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.question may 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

📥 Commits

Reviewing files that changed from the base of the PR and between b914914 and b79497b.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is 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_PROMPT constant in init.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 hasGunshiInstruction function properly catches file read errors and returns false, preventing crashes when checking non-existent files.


63-71: LGTM on the fileExists helper.

Using fs.access is 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 gunshi as a production dependency and @gunshi/docs as a dev dependency. Error handling with process.exit(1) ensures proper exit codes.

@kazupon kazupon added the feature Includes new features label Dec 6, 2025

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.md and .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:

  1. Splitting the code block into two separate examples (one for CLAUDE.md, one for .cursor rules)
  2. Adding explicit instructions about file paths and syntax requirements
  3. 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 kazupon left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ryoppippi
Great works!
I'll merge your PR!

Thank you!

@kazupon
kazupon merged commit 7180f2d into kazupon:main Dec 6, 2025
9 checks passed
@ryoppippi
ryoppippi deleted the docs-init-cli branch December 7, 2025 09:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Includes new features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants