Skip to content

fix(link): install agent skills before creating template subdir#70

Open
tonychang04 wants to merge 2 commits intomainfrom
fix/link-install-skills-before-mkdir
Open

fix(link): install agent skills before creating template subdir#70
tonychang04 wants to merge 2 commits intomainfrom
fix/link-install-skills-before-mkdir

Conversation

@tonychang04
Copy link
Copy Markdown
Contributor

@tonychang04 tonychang04 commented Apr 17, 2026

Summary

  • In link --template <name>, move installSkills() to run before mkdir/chdir, so skills install in the parent cwd instead of inside the newly-created project subdir.
  • Non-template link flow is unchanged.

Why

When the agent (Claude Code, Cursor, etc.) is already driving the CLI from a workspace and link --template creates a subproject directory, installing skills inside that subdir hides them from the agent's current session. Moving the install to the parent fixes this.

Per each agent's docs, skills installed in the parent still load from subdirs for: Claude Code, Windsurf, Codex CLI (AGENTS.md), Gemini CLI, Qwen, Kilo, Augment, Antigravity, and GitHub Copilot (opt-in).

Caveat: Cursor, Cline, Roo, Qoder, and likely Trae do not walk up parent directories. Users of those agents who later open the new project dir as a fresh workspace won't get skills auto-loaded — they'd need to re-run npx skills add insforge/agent-skills inside the project.

Test plan

  • npm run lint — passes (69 tests)
  • npm run build — passes
  • Manual: insforge link --template react — verify skills install in cwd, then subdir is created and template downloads into it
  • Manual: insforge link (no template) — verify behavior unchanged

🤖 Generated with Claude Code

Note

Fix agent skill installation to run in the current directory before creating the template subdirectory

When --template is used in link, installSkills was previously called inside the newly created project subdirectory. It now runs in the current working directory immediately after template validation, before the project directory is created.

  • Behavioral Change: skills are installed in the calling directory rather than the new project subdirectory.

Macroscope summarized 26cbed5.

Summary by CodeRabbit

  • Chores
    • Updated package version to 0.1.51
    • Adjusted the initialization sequence for template-based project linking to install agent skills earlier in the process

Move installSkills() in the --template branch to run before
mkdir/chdir so skills land in the parent directory. Claude Code,
Windsurf, Codex, Gemini, Qwen, Kilo, Augment, and Antigravity all
walk up parent directories for skills/rules, so this works for the
common case of an agent already driving the CLI from the workspace.

Non-template link flow is unchanged.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 17, 2026

Walkthrough

Version bump to @insforge/cli from 0.1.50 to 0.1.51. In the template-enabled flow, installSkills(json) is now invoked immediately after validating opts.template, before project directory creation and template download, moving it earlier in the execution sequence.

Changes

Cohort / File(s) Summary
Version Bump
package.json
Updated @insforge/cli version from 0.1.50 to 0.1.51.
Template Flow Refactoring
src/commands/projects/link.ts
Moved installSkills(json) call to execute immediately after opts.template validation, before project subdirectory creation and template download; removed the prior installation call from the end of the template flow.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Suggested reviewers

  • jwfing
  • Fermionic-Lyu
  • CarmenDou

Poem

🐰 Hop, skip, and a version bump we go,
From fifty to fifty-one, the CLI will know!
installSkills hops early now, no delays in sight,
Before directories bloom, the flow's just right!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: moving the installSkills() call to before creating the template subdirectory in the link command.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/link-install-skills-before-mkdir

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

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/commands/projects/link.ts`:
- Around line 205-207: installSkills(json) is being invoked before the directory
prompt and collision checks, causing skills to be installed in the parent
directory even if the user cancels or the target directory already exists; move
the installSkills(json) call so it runs after the directory validation/prompt
logic and after the code that creates or confirms the project subdirectory (the
block that checks for existing directory and prompts the user), ensuring skills
are installed only once the target project directory is validated/created and
not before.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4f6174ec-9a46-41b2-a3f9-61d8581ed149

📥 Commits

Reviewing files that changed from the base of the PR and between cea7763 and 26cbed5.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (2)
  • package.json
  • src/commands/projects/link.ts

Comment on lines +205 to +207
// Install agent skills in the current directory before creating the project subdir
await installSkills(json);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Delay skill installation until after directory validation succeeds.

At Line 205, side effects now occur before directory prompt/collision checks. If the user cancels or the directory already exists, skills still get installed in the parent directory even though template setup does not proceed.

Suggested adjustment
-          // Install agent skills in the current directory before creating the project subdir
-          await installSkills(json);
-
           // Ask for directory name
           let dirName = project.name;
           if (!json) {
             const inputDir = await prompts.text({
@@
           const templateDir = path.resolve(process.cwd(), dirName);
           const dirExists = await fs.stat(templateDir).catch(() => null);
           if (dirExists) {
             throw new CLIError(`Directory "${dirName}" already exists.`);
           }
+
+          // Install agent skills in parent cwd only after validation passes
+          await installSkills(json);
+
           await fs.mkdir(templateDir);
           process.chdir(templateDir);
📝 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
// Install agent skills in the current directory before creating the project subdir
await installSkills(json);
// Ask for directory name
let dirName = project.name;
if (!json) {
const inputDir = await prompts.text({
// ... existing prompt code ...
}
const templateDir = path.resolve(process.cwd(), dirName);
const dirExists = await fs.stat(templateDir).catch(() => null);
if (dirExists) {
throw new CLIError(`Directory "${dirName}" already exists.`);
}
// Install agent skills in parent cwd only after validation passes
await installSkills(json);
await fs.mkdir(templateDir);
process.chdir(templateDir);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/commands/projects/link.ts` around lines 205 - 207, installSkills(json) is
being invoked before the directory prompt and collision checks, causing skills
to be installed in the parent directory even if the user cancels or the target
directory already exists; move the installSkills(json) call so it runs after the
directory validation/prompt logic and after the code that creates or confirms
the project subdirectory (the block that checks for existing directory and
prompts the user), ensuring skills are installed only once the target project
directory is validated/created and not before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant