Skip to content

feat: add selective skill installation to reduce context token usage - #107

Merged
shunkakinoki merged 2 commits into
mainfrom
feat/selective-skill-install
Mar 31, 2026
Merged

feat: add selective skill installation to reduce context token usage#107
shunkakinoki merged 2 commits into
mainfrom
feat/selective-skill-install

Conversation

@shunkakinoki

@shunkakinoki shunkakinoki commented Mar 31, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add per-repo skill selection to SKILLS.txt format (repo skill1,skill2,...)
  • Update skills-install Makefile target to parse new format and pass --skill flag
  • Add skills-clean target and integrate into make sync for clean reinstalls
  • Curate essential skills across all 34 repos (828 -> ~193 skills, ~76% reduction)
  • Estimated context token savings: ~62k -> ~15k tokens (~76% reduction)

Test plan

  • Run make sync and verify only selected skills are installed
  • Verify npx skills add <repo> --global --yes --skill "a,b" works for selective install
  • Confirm skills-clean removes all skill directories
  • Check Claude Code /context shows reduced skill token usage

🤖 Generated with Claude Code


Summary by cubic

Adds per-repo selective skill installation to cut context token usage. Curates SKILLS.txt from 828 to ~193 skills across 34 repos, reducing context from ~62k to ~15k tokens (~76%).

  • New Features

    • New SKILLS.txt format supports per-repo skill lists: repo skill1,skill2,... (omit to install all; comments/blank lines allowed).
    • skills-install parses the file and passes --skill to bunx skills add for selective installs.
    • Added skills-clean and run it in make sync for clean reinstalls; skills-install-repo now supports SKILLS=a,b,c.
  • Migration

    • Customize SKILLS.txt using the new format where needed.
    • Run make sync to clean and reinstall selected skills.
    • For a single repo: make skills-install-repo REPO=owner/repo SKILLS=a,b.

Written for commit 7fc07fa. Summary will update on new commits.

- SKILLS.txt now supports per-repo skill selection (repo skill1,skill2,...)
- skills-install parses new format and passes --skill flag to bunx
- Add skills-clean target, integrate into make sync
- Curate essential skills per repo (828 -> ~193 skills, ~76% reduction)
- Estimated context savings: ~62k -> ~15k tokens
Copilot AI review requested due to automatic review settings March 31, 2026 05:08
@coderabbitai

coderabbitai Bot commented Mar 31, 2026

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 88f861ce-c151-47fe-999a-dcfe39216cad

📥 Commits

Reviewing files that changed from the base of the PR and between 52d2e4f and 7fc07fa.

📒 Files selected for processing (1)
  • Makefile

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.


📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Selective skill installation per repository — choose specific skills instead of installing all.
  • Chores

    • Cleaner sync flow with automatic removal of previously installed skills before reinstalling.
    • Updated skills configuration to a structured format supporting per-repo skill lists and comments for clearer management.

Walkthrough

The Makefile's skill-install workflow now cleans existing global skills, then parses SKILLS.txt line-by-line to install either per-repo selected skills or all skills. skills-clean is added and skills-install-repo accepts an optional SKILLS=a,b,c parameter; the prior SKILL_REPOS parsing variable was removed.

Changes

Cohort / File(s) Summary
Makefile skill installation refactoring
Makefile
Added skills-clean PHONY target that deletes existing global skill directories. sync now invokes skills-clean before skills-install. skills-install reads $(SKILLS_FILE)/SKILLS.txt line-by-line (skips comments/blank lines) and calls skills-install-repo per line. skills-install-repo accepts optional SKILLS=a,b,c to install only specified skills via --skill; otherwise installs all. Removed SKILL_REPOS upfront parsing variable.
Skills configuration restructuring
SKILLS.txt
Rewrote entries to support repo [skill1,skill2,...] semantics with comments. Many repo lines now list curated skill subsets; some repos were removed or re-listed with explicit skill filters; some repos remain with no skill list (meaning install all).

Sequence Diagram

sequenceDiagram
    participant User
    participant Makefile as Makefile (sync)
    participant CommandsSync as commands-sync
    participant SkillsClean as skills-clean
    participant SKILLSFile as SKILLS.txt
    participant SkillsInstall as skills-install
    participant SkillsInstallRepo as skills-install-repo

    User->>Makefile: make sync
    Makefile->>CommandsSync: run commands-sync
    CommandsSync-->>Makefile: done
    Makefile->>SkillsClean: run skills-clean
    SkillsClean->>SkillsClean: remove contents of $(SKILLS_TARGET_DIRS)
    SkillsClean-->>Makefile: done
    Makefile->>SkillsInstall: run skills-install
    SkillsInstall->>SKILLSFile: read lines (skip comments/blank)
    SKILLSFile-->>SkillsInstall: repo + optional skill list
    loop per repo entry
        SkillsInstall->>SkillsInstallRepo: invoke with REPO (+ SKILLS if present)
        alt SKILLS specified
            SkillsInstallRepo->>SkillsInstallRepo: bunx skills add ... --skill each
        else no SKILLS
            SkillsInstallRepo->>SkillsInstallRepo: bunx skills add (all)
        end
        SkillsInstallRepo-->>SkillsInstall: repo install complete
    end
    SkillsInstall-->>Makefile: done
    Makefile-->>User: sync finished
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Suggested labels

enhancement

Poem

🐇 I hopped through lines and cleared the ground,
Reordered skills where answers are found,
Per-repo petals picked just right,
Clean then install — oh what a sight! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: add selective skill installation to reduce context token usage' directly and clearly describes the main change: implementing selective skill installation with a specific benefit (reducing context token usage).
Description check ✅ Passed The description comprehensively details the changeset: new SKILLS.txt format, Makefile updates, skills-clean target, and 76% reduction in installed skills/context tokens. It is directly related to the changes in the pull request.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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 feat/selective-skill-install

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.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No issues found across 2 files

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
Makefile (1)

34-37: Prefer $(MAKE) for recursive targets.

Using $(MAKE) preserves flags/jobserver behavior across nested invocations.

Proposed fix
-	`@make` ruler-apply-global
+	@$(MAKE) ruler-apply-global
 	`@make` commands-sync
-	`@make` skills-clean
-	`@make` skills-install
-	`@make` skills-sync
-	`@make` mcp-sync
-	`@make` ruler-dotdirs-sync
+	@$(MAKE) skills-clean
+	@$(MAKE) skills-install
+	@$(MAKE) skills-sync
+	@$(MAKE) mcp-sync
+	@$(MAKE) ruler-dotdirs-sync
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Makefile` around lines 34 - 37, Replace literal make invocations with $(MAKE)
for recursive targets to preserve flags and jobserver behavior: change the
invocations of ruler-apply-global, commands-sync, skills-clean, and
skills-install (currently called via "make") to use "$(MAKE)
ruler-apply-global", "$(MAKE) commands-sync", "$(MAKE) skills-clean", and
"$(MAKE) skills-install" respectively so recursive make inherits flags and -j
behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@Makefile`:
- Around line 83-86: The cleanup loop over SKILLS_TARGET_DIRS currently only
removes non-hidden entries via rm -rf "$$target"/*; update the loop that
iterates over $(SKILLS_TARGET_DIRS) (the shell variable target) to remove all
entries including dotfiles safely—for example replace the rm line with a safe
command that removes every child entry without touching the parent directory
such as using find: find "$$target" -mindepth 1 -maxdepth 1 -exec rm -rf -- {} +
so hidden files and dirs are also removed while avoiding removing "." or "..".

In `@SKILLS.txt`:
- Line 34: Replace the lowercase platform label "github/awesome-copilot" with
the official-casing "GitHub/awesome-copilot" in SKILLS.txt (update the string
"github/awesome-copilot (257 total) - keep essential dev/infra skills" to use
"GitHub") so the comment text uses the official platform casing.

---

Nitpick comments:
In `@Makefile`:
- Around line 34-37: Replace literal make invocations with $(MAKE) for recursive
targets to preserve flags and jobserver behavior: change the invocations of
ruler-apply-global, commands-sync, skills-clean, and skills-install (currently
called via "make") to use "$(MAKE) ruler-apply-global", "$(MAKE) commands-sync",
"$(MAKE) skills-clean", and "$(MAKE) skills-install" respectively so recursive
make inherits flags and -j behavior.
🪄 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: 0306bcb2-8de6-4ae9-9ba2-803003ed6d60

📥 Commits

Reviewing files that changed from the base of the PR and between 63d1ffa and 52d2e4f.

📒 Files selected for processing (2)
  • Makefile
  • SKILLS.txt

Comment thread Makefile
Comment on lines +83 to +86
@for target in $(SKILLS_TARGET_DIRS); do \
if [ -d "$$target" ]; then \
rm -rf "$$target"/*; \
echo "Cleaned $$target"; \

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

🧩 Analysis chain

🏁 Script executed:

# First, find and examine the Makefile
fd -t f "Makefile$" --maxdepth 2

Repository: shunkakinoki/dotagents

Length of output: 74


🏁 Script executed:

# Look for the Makefile and examine the context around lines 83-86
if [ -f "Makefile" ]; then
  echo "=== Makefile found ==="
  sed -n '75,95p' Makefile
fi

Repository: shunkakinoki/dotagents

Length of output: 895


🏁 Script executed:

# Test rm -rf behavior with hidden files to verify the claim
# Create a test directory structure to validate the issue
mkdir -p /tmp/test_cleanup/testdir
cd /tmp/test_cleanup/testdir

# Add visible and hidden files
touch visible_file.txt .hidden_file .another_hidden
mkdir visible_dir .hidden_dir

# Test 1: rm -rf testdir/*
echo "Before rm -rf testdir/*:"
ls -la testdir/

# Clone the directory for testing
cp -r testdir testdir_copy1
rm -rf testdir_copy1/*
echo "After rm -rf testdir_copy1/*:"
ls -la testdir_copy1/
echo "Hidden files remain: $(ls -la testdir_copy1/ | grep -c '^\.')"

# Test 2: The proposed fix pattern
cp -r testdir testdir_copy2
rm -rf testdir_copy2/* testdir_copy2/.[!.]* testdir_copy2/..?*
echo "After proposed fix (rm -rf testdir_copy2/* testdir_copy2/.[!.]* testdir_copy2/..?*):"
ls -la testdir_copy2/
echo "Remaining items: $(ls -la testdir_copy2/ | wc -l)"

Repository: shunkakinoki/dotagents

Length of output: 674


🏁 Script executed:

# Test rm -rf behavior with hidden files
mkdir -p /tmp/rm_test/target
cd /tmp/rm_test

# Create test files and directories
touch target/visible_file.txt
touch target/.hidden_file
touch target/.bashrc
mkdir target/.hidden_dir
mkdir target/visible_dir

echo "=== Before rm -rf target/* ==="
ls -la target/ | tail -n +4

# Test the current approach
rm -rf target/*

echo ""
echo "=== After rm -rf target/* ==="
ls -la target/ | tail -n +4

if [ -f target/.hidden_file ] || [ -d target/.hidden_dir ]; then
  echo "CONFIRMED: Hidden files/dirs remain after rm -rf target/*"
else
  echo "Hidden files were removed"
fi

Repository: shunkakinoki/dotagents

Length of output: 664


🏁 Script executed:

# Now test the proposed fix
mkdir -p /tmp/rm_test2/target
cd /tmp/rm_test2

# Create test files
touch target/visible_file.txt
touch target/.hidden_file
touch target/.bashrc
mkdir target/.hidden_dir

echo "=== Before proposed fix ==="
ls -la target/ | tail -n +4

# Test the proposed fix: rm -rf target/* target/.[!.]* target/..?*
rm -rf target/* target/.[!.]* target/..?*

echo ""
echo "=== After proposed fix (rm -rf target/* target/.[!.]* target/..?*) ==="
ls -la target/ | tail -n +4

remaining=$(ls -la target/ | wc -l)
if [ "$remaining" -le 3 ]; then
  echo "SUCCESS: All files removed (only . and .. remain)"
else
  echo "Some files remain"
fi

Repository: shunkakinoki/dotagents

Length of output: 457


skills-clean does not remove hidden files, leaving partial cleanup that can affect reinstall behavior.

Line 85 only deletes *, which excludes dotfiles and dotdirectories. These remnants can interfere with a clean reinstall.

Proposed fix
-			rm -rf "$$target"/*; \
+			rm -rf "$$target"/* "$$target"/.[!.]* "$$target"/..?*; \
📝 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
@for target in $(SKILLS_TARGET_DIRS); do \
if [ -d "$$target" ]; then \
rm -rf "$$target"/*; \
echo "Cleaned $$target"; \
`@for` target in $(SKILLS_TARGET_DIRS); do \
if [ -d "$$target" ]; then \
rm -rf "$$target"/* "$$target"/.[!.]* "$$target"/..?*; \
echo "Cleaned $$target"; \
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Makefile` around lines 83 - 86, The cleanup loop over SKILLS_TARGET_DIRS
currently only removes non-hidden entries via rm -rf "$$target"/*; update the
loop that iterates over $(SKILLS_TARGET_DIRS) (the shell variable target) to
remove all entries including dotfiles safely—for example replace the rm line
with a safe command that removes every child entry without touching the parent
directory such as using find: find "$$target" -mindepth 1 -maxdepth 1 -exec rm
-rf -- {} + so hidden files and dirs are also removed while avoiding removing
"." or "..".

Comment thread SKILLS.txt
# getsentry/skills (24 total) - keep dev workflow skills
getsentry/skills agents-md,claude-settings-audit,code-review,code-simplifier,commit,create-branch,create-pr,find-bugs,gh-review-requests,gha-security-review,iterate-pr,pr-writer,security-review

# github/awesome-copilot (257 total) - keep essential dev/infra skills

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

Use official platform casing in comment text.

Please change github/awesome-copilot description label text to GitHub for consistency/readability.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~34-~34: The official name of this software platform is spelled with a capital “H”.
Context: ...iterate-pr,pr-writer,security-review # github/awesome-copilot (257 total) - keep esse...

(GITHUB)


[uncategorized] ~34-~34: The official name of this software platform is spelled with a capital “H”.
Context: ...otal) - keep essential dev/infra skills github/awesome-copilot chrome-devtools,convent...

(GITHUB)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@SKILLS.txt` at line 34, Replace the lowercase platform label
"github/awesome-copilot" with the official-casing "GitHub/awesome-copilot" in
SKILLS.txt (update the string "github/awesome-copilot (257 total) - keep
essential dev/infra skills" to use "GitHub") so the comment text uses the
official platform casing.

Copilot AI 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.

Pull request overview

Adds selective, per-repo skill installation support to reduce the globally installed skill set (and therefore context token usage) during make sync.

Changes:

  • Replaces SKILLS.txt with a new format that optionally lists a comma-separated subset of skills per repo.
  • Updates skills-install to parse the new format and call bunx skills add ... --skill "a,b,c" when a subset is provided.
  • Adds skills-clean and wires it into make sync to force clean reinstalls.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
SKILLS.txt Converts list of repos into a curated repo→skills mapping (or “install all”) to reduce installed skill volume.
Makefile Adds skills-clean, updates skills-install parsing/installation logic, and adjusts sync flow to include cleaning and global ruler application.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Makefile
if bunx skills add $$repo --global --yes; then \
echo "✓ Installed $$repo"; \
skills-install: ## Install skills from SKILLS.txt (supports per-repo skill selection).
@grep -v '^\s*#' $(SKILLS_FILE) | grep -v '^\s*$$' | while IFS= read -r line; do \

Copilot AI Mar 31, 2026

Copy link

Choose a reason for hiding this comment

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

The grep filters use \s (e.g., grep -v '^\s*#'), but standard grep (BRE) doesn’t recognize \s as whitespace. This will fail to strip comments/blank lines and can result in trying to install a repo named # or an empty repo. Use POSIX character classes like ^[[:space:]]*# / ^[[:space:]]*$, or replace the whole pipeline with a single awk that skips comment/empty lines.

Suggested change
@grep -v '^\s*#' $(SKILLS_FILE) | grep -v '^\s*$$' | while IFS= read -r line; do \
@awk '!/^[[:space:]]*#/ && NF' $(SKILLS_FILE) | while IFS= read -r line; do \

Copilot uses AI. Check for mistakes.
Comment thread Makefile
Comment on lines +91 to 113
skills-install: ## Install skills from SKILLS.txt (supports per-repo skill selection).
@grep -v '^\s*#' $(SKILLS_FILE) | grep -v '^\s*$$' | while IFS= read -r line; do \
repo=$$(echo "$$line" | awk '{print $$1}'); \
skills=$$(echo "$$line" | awk '{print $$2}'); \
if [ -n "$$skills" ]; then \
echo "Installing selected skills from $$repo ($$skills)..."; \
if bunx skills add $$repo --global --yes --skill "$$skills"; then \
echo "✓ Installed $$repo (selective)"; \
else \
echo "✗ Failed to install $$repo"; \
exit 1; \
fi; \
else \
echo "✗ Failed to install $$repo"; \
exit 1; \
echo "Installing all skills from $$repo..."; \
if bunx skills add $$repo --global --yes; then \
echo "✓ Installed $$repo (all)"; \
else \
echo "✗ Failed to install $$repo"; \
exit 1; \
fi; \
fi; \
done
@echo "All external skills installed successfully."

Copilot AI Mar 31, 2026

Copy link

Choose a reason for hiding this comment

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

skills-install will report success even if $(SKILLS_FILE) is missing/unreadable: in a pipeline, the exit code is taken from the final while ...; do ...; done, which will exit 0 if it reads no lines, masking grep errors. Add an explicit existence/readability check for $(SKILLS_FILE) (and ideally fail if it contains no valid entries) before starting the install loop.

Copilot uses AI. Check for mistakes.
Comment thread Makefile
Comment on lines 33 to +34
sync: ruler-prepare ## Sync project commands, skills, and MCP configuration to assistant-specific directories.
@make ruler-apply-global

Copilot AI Mar 31, 2026

Copy link

Choose a reason for hiding this comment

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

sync already has ruler-prepare as a prerequisite, and the recipe also calls make ruler-apply-global which itself depends on ruler-prepare. Because these are .PHONY, this runs the prepare steps twice on every make sync. Consider making sync depend on ruler-apply-global (instead of ruler-prepare) and removing the explicit make ruler-apply-global line, or otherwise restructuring so ruler-prepare only runs once per sync.

Suggested change
sync: ruler-prepare ## Sync project commands, skills, and MCP configuration to assistant-specific directories.
@make ruler-apply-global
sync: ruler-apply-global ## Sync project commands, skills, and MCP configuration to assistant-specific directories.

Copilot uses AI. Check for mistakes.
Comment thread Makefile
skills-clean: ## Remove all globally installed skills for a clean reinstall.
@for target in $(SKILLS_TARGET_DIRS); do \
if [ -d "$$target" ]; then \
rm -rf "$$target"/*; \

Copilot AI Mar 31, 2026

Copy link

Choose a reason for hiding this comment

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

skills-clean uses rm -rf "$$target"/*, which won’t remove dotfiles/directories (e.g., .git, .DS_Store) under the skills dir. If hidden entries can exist, the cleanup will be incomplete and may interfere with a clean reinstall. Consider using find "$$target" -mindepth 1 -maxdepth 1 -exec rm -rf {} + (or equivalent) to remove all entries.

Suggested change
rm -rf "$$target"/*; \
find "$$target" -mindepth 1 -maxdepth 1 -exec rm -rf {} +; \

Copilot uses AI. Check for mistakes.
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