Skip to content

fix(link): install agent skills in the template directory, not the parent#64

Merged
tonychang04 merged 2 commits intomainfrom
fix/install-skills-in-template-dir
Apr 13, 2026
Merged

fix(link): install agent skills in the template directory, not the parent#64
tonychang04 merged 2 commits intomainfrom
fix/install-skills-in-template-dir

Conversation

@tonychang04
Copy link
Copy Markdown
Contributor

@tonychang04 tonychang04 commented Apr 13, 2026

Summary

When running `insforge link --template `, the skill-install step (`.claude/`, `.codex/`, `.cursor/`, …) fired in the original cwd before the user was prompted for the subdirectory name. Result: the skills ended up one level above the project, where no agent would actually find them.

New flow for `--template`:

  1. Prompt for directory name
  2. `mkdir` + `chdir` into it, save project config
  3. Download template
  4. `npm install`
  5. Install agent skills inside the project directory ← moved here
  6. Report `cli.link` usage
  7. Show Next Steps

Non-template `link` is unchanged (skills still install in cwd), just refactored so both branches share the same ordering logic.

Version bump 0.1.46 → 0.1.47.

Test plan

  • `insforge link --template react` from an empty dir — confirm `.claude/` and friends land inside the new project subdirectory, not the parent.
  • Plain `insforge link` (no template) — skills still install in cwd.
  • `cli.link` event still fires in both branches.

🤖 Generated with Claude Code

Note

Fix agent skill installation to run in the template directory, not the parent

  • Moves installSkills and reportCliUsage calls to run after template download and dependency installation in the template path, rather than unconditionally before template handling.
  • In the no-template path, installSkills and reportCliUsage now run before showing dashboard guidance.
  • Updates a suggested prompt string in the no-template guidance to include 'and deploy it to a live URL'.

Macroscope summarized 55c1077.

Summary by CodeRabbit

  • Bug Fixes

    • Fixed project linking workflow so skill installation and CLI usage reporting run in the correct project directory and after templates are prepared, ensuring prompts, dashboard output, and optional installs occur in the right context.
  • Chores

    • Bumped package version to 0.1.47.

…rent

When --template is passed, the old flow installed the skills (.claude,
.codex, etc.) in the cwd *before* asking for the subdirectory name, so
the skills landed one level up from the actual project. Now we prompt
for the directory, create it, cd in, download the template, run npm
install, and only then install the skills — so they sit alongside the
template files where agents will actually find them.

Version bump 0.1.46 → 0.1.47.

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

coderabbitai bot commented Apr 13, 2026

Walkthrough

Version bumped from 0.1.46 → 0.1.47 in package manifest. Reorganized control flow in the project link command so installSkills() and reportCliUsage() are invoked after template handling (and within the correct working directory) for both template and no-template paths.

Changes

Cohort / File(s) Summary
Package Version
package.json
Version bumped from 0.1.46 to 0.1.47.
Command Control Flow
src/commands/projects/link.ts
Reordered logic so installSkills(json) and reportCliUsage('cli.link', ...) run after template directory creation/config save/npm install/checks when --template is used, and run in the appropriate branch for the no-template case; adjusted prompt/dashboard emission and one prompt text update (“and deploy it to a live URL”).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • jwfing
  • CarmenDou
  • Fermionic-Lyu

Poem

🐰 I nibbled code beneath the moonlight bright,
Bumped the version, set the flow just right,
Skills now sprout where templates lie,
Prompts sing true beneath the sky,
A tiny hop for CLI delight.

🚥 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 clearly and concisely summarizes the main bug fix: skills installation now occurs in the template directory rather than the parent directory.
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/install-skills-in-template-dir

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

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 261-262: The code currently calls installSkills(json)
unconditionally even when template download failed; update the flow to only call
installSkills when the template actually downloaded (e.g., check the
templateDownloaded flag or have downloadTemplate()/downloadGitHubTemplate()
return a success boolean) so that installSkills is skipped if templateDownloaded
is false; adjust downloadTemplate/downloadGitHubTemplate to return success (or
rethrow errors) if needed and use that value to gate the call to
installSkills(json).
🪄 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: b442c319-2c60-44b8-b68f-bcb4180254c9

📥 Commits

Reviewing files that changed from the base of the PR and between 6a78962 and e6629e9.

📒 Files selected for processing (2)
  • package.json
  • src/commands/projects/link.ts

Comment on lines +261 to +262
// Install agent skills inside the project directory
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

Gate skill installation on templateDownloaded.

If downloadTemplate() / downloadGitHubTemplate() fails, those helpers return normally, so this still installs .claude/, .codex/, etc. into a partial directory even though Line 245 says to proceed only when the template actually downloaded.

Suggested fix
-          // Install agent skills inside the project directory
-          await installSkills(json);
+          // Install agent skills only when the template actually downloaded
+          if (templateDownloaded) {
+            await installSkills(json);
+          }
           await reportCliUsage('cli.link', true, 6, projectConfig);

Based on learnings: downloadTemplate and downloadGitHubTemplate catch/log failures internally and return normally, so template-init failures do not reach the outer catch block.

📝 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 inside the project directory
await installSkills(json);
// Install agent skills only when the template actually downloaded
if (templateDownloaded) {
await installSkills(json);
}
await reportCliUsage('cli.link', true, 6, projectConfig);
🤖 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 261 - 262, The code currently
calls installSkills(json) unconditionally even when template download failed;
update the flow to only call installSkills when the template actually downloaded
(e.g., check the templateDownloaded flag or have
downloadTemplate()/downloadGitHubTemplate() return a success boolean) so that
installSkills is skipped if templateDownloaded is false; adjust
downloadTemplate/downloadGitHubTemplate to return success (or rethrow errors) if
needed and use that value to gate the call to installSkills(json).

Nudges users toward the end-to-end flow (build + deploy) instead of
leaving them on localhost after their first agent session.

Co-Authored-By: Claude Opus 4.6 (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.

♻️ Duplicate comments (1)
src/commands/projects/link.ts (1)

261-263: ⚠️ Potential issue | 🟠 Major

Skip skill installation when the template download failed.

installSkills(json) on Line 262 still runs even when templateDownloaded is falsy, so a failed template init can still leave .claude/, .codex/, etc. in a partial directory. Guard the skill install behind the same check you already use for npm install / next steps.

Suggested fix
           // Install agent skills inside the project directory
-          await installSkills(json);
+          if (templateDownloaded) {
+            await installSkills(json);
+          }
           await reportCliUsage('cli.link', true, 6, projectConfig);

Based on learnings: downloadTemplate and downloadGitHubTemplate catch/log failures internally and return normally, so template-init failures do not reach the outer catch block.

🤖 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 261 - 263, The call to
installSkills(json) runs even when templateDownloaded is falsy, causing partial
skill files to be installed after a failed template init; update the control
flow so installSkills(json) is executed only when templateDownloaded is truthy
(the same guard used for the npm install/next-steps block), i.e., wrap or move
the installSkills(json) invocation behind the templateDownloaded check so it is
skipped when downloadTemplate/downloadGitHubTemplate failed.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@src/commands/projects/link.ts`:
- Around line 261-263: The call to installSkills(json) runs even when
templateDownloaded is falsy, causing partial skill files to be installed after a
failed template init; update the control flow so installSkills(json) is executed
only when templateDownloaded is truthy (the same guard used for the npm
install/next-steps block), i.e., wrap or move the installSkills(json) invocation
behind the templateDownloaded check so it is skipped when
downloadTemplate/downloadGitHubTemplate failed.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c9da7447-e82a-44e5-bd8a-52f82297b914

📥 Commits

Reviewing files that changed from the base of the PR and between e6629e9 and 55c1077.

📒 Files selected for processing (1)
  • src/commands/projects/link.ts

@tonychang04 tonychang04 enabled auto-merge (squash) April 13, 2026 19:14
@tonychang04 tonychang04 merged commit 406c097 into main Apr 13, 2026
3 checks passed
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.

2 participants