Skip to content

Comments

feat(ralph-specum): auto-discover and invoke skills on start#98

Open
tzachbon wants to merge 11 commits intomainfrom
feat/smart-skill-swap-retry
Open

feat(ralph-specum): auto-discover and invoke skills on start#98
tzachbon wants to merge 11 commits intomainfrom
feat/smart-skill-swap-retry

Conversation

@tzachbon
Copy link
Owner

@tzachbon tzachbon commented Feb 22, 2026

Summary

  • Adds automatic skill discovery to both normal and quick mode start flows
  • Scans all ralph-specum skill SKILL.md frontmatter descriptions, tokenizes them, and matches against the user's goal text using keyword overlap (threshold >= 2 words)
  • Two discovery passes: Pass 1 at start (goal text only), Pass 2 post-research (goal + Executive Summary from research.md) to catch skills missed initially
  • Discovered skills are invoked immediately via Skill({ skill: "ralph-specum:<name>" }) with no user confirmation
  • State tracked in .ralph-state.json discoveredSkills array with { name, matchedAt, invoked } objects
  • Progress logged to .progress.md under ## Skill Discovery / ### Post-Research Retry sections
  • Error handling for unreadable SKILL.md, missing descriptions, invocation failures, and no matches
  • Version bumped to 4.2.0

Files Changed

  • plugins/ralph-specum/commands/start.md — Added Step 3 (Skill Discovery Pass 1) and step 12 (Pass 2) in normal mode flow; added discoveredSkills to state init
  • plugins/ralph-specum/references/quick-mode.md — Added step 9 (Pass 1) and step 12 (Pass 2) in quick mode flow; added discoveredSkills to state init
  • plugins/ralph-specum/.claude-plugin/plugin.json — Version bump 4.1.2 → 4.2.0
  • .claude-plugin/marketplace.json — Version bump 4.1.2 → 4.2.0

Test plan

  • Structural grep checks: all 4 discovery passes present with tokenization rules, thresholds, state updates, and progress logging
  • All 6 skills verified discoverable via SKILL.md frontmatter
  • Tokenization manually verified against real skill descriptions
  • CLAUDE_PLUGIN_ROOT paths verified (no hardcoded paths)
  • JSON validity of plugin.json and marketplace.json confirmed
  • All 22 acceptance criteria traced to implementation

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Introduced multi-pass Skill Discovery flow for improved skill matching accuracy
    • Enhanced Quick Mode workflow with refined execution sequence
  • Documentation

    • Updated plugin documentation to reflect new Skill Discovery and Quick Mode processes
    • Added comprehensive task tracking and progress documentation for the feature
  • Chores

    • Bumped plugin version to 4.2.0

tzachbon and others added 11 commits February 22, 2026 16:53
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… passes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link

coderabbitai bot commented Feb 22, 2026

📝 Walkthrough

Walkthrough

The PR bumps the ralph-specum plugin version from 4.1.2 to 4.2.0 across marketplace and plugin configuration files, and introduces comprehensive documentation for a multi-pass Skill Discovery workflow in both normal and quick modes, including new progress tracking and task planning documents.

Changes

Cohort / File(s) Summary
Plugin Version Bump
.claude-plugin/marketplace.json, plugins/ralph-specum/.claude-plugin/plugin.json
Updated ralph-specum plugin version from 4.1.2 to 4.2.0.
Command & Reference Documentation
plugins/ralph-specum/commands/start.md, plugins/ralph-specum/references/quick-mode.md
Reworked Quick Mode and Skill Discovery flows; introduced multi-pass discovery (Pass 1 and Post-Research Retry), step renumbering, new state initialization with discoveredSkills field, updated progress narrative outputs, and new STOP/controller structure for normal mode.
Feature Documentation
specs/smart-skill-swap-retry/.progress.md, specs/smart-skill-swap-retry/tasks.md
Added comprehensive progress tracking document with task completion and verification checkpoints; introduced multi-phase POC plan (Make It Work, Refactoring, Testing, Quality Gates) with 11+ concrete tasks and success criteria.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 A rabbit hops through skill discovery's maze,
Two passes now—swift through the haze!
From 4.1.2 to 4.2.0 we leap,
Quick mode and normal, secrets to keep.
With progress tracked and tasks all laid,
The smart-skill-swap shall not fade! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the main change: adding automatic skill discovery and invocation on start for the ralph-specum plugin, which is the central objective across all modified files.
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
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/smart-skill-swap-retry

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


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.

Copy link

@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: 5

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
plugins/ralph-specum/commands/start.md (1)

11-19: ⚠️ Potential issue | 🟡 Minor

Checklist is stale — missing the new Skill Discovery step.

The top-level checklist still shows the old 5-item structure. Step 3 (Skill Discovery Pass 1) is not listed, "Classify intent" is now part of Step 2 rather than a separate item, and the step numbers for "Scan existing specs" and "Route to action" are off.

🛠️ Proposed fix
 Create a task for each item and complete in order:
 
 1. **Handle branch** -- check git branch, create/switch if needed
 2. **Parse input** -- extract name, goal, flags from $ARGUMENTS; classify intent
-3. **Classify intent** -- determine what user wants (new spec, resume, quick mode)
-4. **Scan existing specs** -- find matching or related specs
-5. **Route to action** -- invoke appropriate flow (new, resume, or quick mode)
+3. **Skill Discovery Pass 1** -- scan skills and match against goal text (normal mode only)
+4. **Scan existing specs** -- find matching or related specs
+5. **Route to action** -- invoke appropriate flow (new, resume, or quick mode)
+6. **Quick Mode Flow** -- follow quick-mode.md sequence if --quick flag present
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@plugins/ralph-specum/commands/start.md` around lines 11 - 19, The top-level
checklist is missing the new "Skill Discovery (Pass 1)" step and the numbering
is incorrect; update the checklist to insert a new item "3. Skill Discovery
(Pass 1) -- detect required skills and capabilities" after "Parse input",
renumber the subsequent items so "Classify intent" remains correctly placed
(either as its own step or clearly noted under "Parse input" per current
design), and ensure the existing items "Handle branch", "Parse input", "Classify
intent", "Scan existing specs", and "Route to action" appear with correct order
and numbering exactly as shown in the diff so the flow reflects the new Skill
Discovery phase.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@plugins/ralph-specum/commands/start.md`:
- Around line 162-172: Update the second-pass logging instruction so the wording
matches the progress template: change the inline log text `- No skills matched`
to `- No new skills matched` in plugins/ralph-specum/commands/start.md (the step
describing Pass 2 and the Appendix "Post-Research Retry") and apply the same
change in quick-mode.md Step 12.6 so both the instruction and the `###
Post-Research Retry` template use the exact phrase `- No new skills matched`.
- Around line 41-72: Pass 1 discovery results are being overwritten because New
Flow initializes .ralph-state.json after Step 3 writes discoveredSkills; move
the Pass 1 discovery block so it runs after state initialization in the "New
Flow" (i.e., run the skill discovery once the .ralph-state.json exists) or
change the state init to merge existing discoveredSkills instead of resetting
them. Specifically, relocate the Step 3 "Skill Discovery Pass 1" logic into the
New Flow between current step 7 (state init) and step 8 (create .progress.md) or
modify the state initialization to merge rather than replace discoveredSkills;
ensure references to .ralph-state.json and the discoveredSkills array are
preserved and that deduplication logic (checking invoked:true) still runs before
invoking Skill({ skill: "ralph-specum:<name>" }).

In `@plugins/ralph-specum/references/quick-mode.md`:
- Around line 147-157: Summary: The "Pass 2" no-match log wording is
inconsistent between the instruction and the Post-Research Retry template;
standardize on "No new skills matched". Fix: update the Pass 2 log instruction
that currently says "- No skills matched" to read "- No new skills matched"
wherever it appears in quick-mode.md and start.md, and ensure the "###
Post-Research Retry" subsection template under "## Skill Discovery" uses the
same phrase; verify any references to the Pass 2 message in related
docs/templates are updated to keep wording consistent.

In `@specs/smart-skill-swap-retry/.progress.md`:
- Line 32: The stopword count in the line starting "Stopword list matches in all
4: a, an, the, to, for, with, and, or, in, on, by, is, be, that, this, of, it,
should, used, when, asks, needs, about (25 words)" is incorrect; update the
parenthetical count to "(23 words)" (or recount and adjust if you intend to
add/remove words) so the text matches the actual list length.

In `@specs/smart-skill-swap-retry/tasks.md`:
- Line 346: Update the phrasing for the Threshold line in
specs/smart-skill-swap-retry/tasks.md by hyphenating the compound modifier:
change the phrase "**Threshold**: 2 word overlap" to "**Threshold**: 2-word
overlap" so the compound adjective is grammatically correct.

---

Outside diff comments:
In `@plugins/ralph-specum/commands/start.md`:
- Around line 11-19: The top-level checklist is missing the new "Skill Discovery
(Pass 1)" step and the numbering is incorrect; update the checklist to insert a
new item "3. Skill Discovery (Pass 1) -- detect required skills and
capabilities" after "Parse input", renumber the subsequent items so "Classify
intent" remains correctly placed (either as its own step or clearly noted under
"Parse input" per current design), and ensure the existing items "Handle
branch", "Parse input", "Classify intent", "Scan existing specs", and "Route to
action" appear with correct order and numbering exactly as shown in the diff so
the flow reflects the new Skill Discovery phase.

Comment on lines +41 to +72
## Step 3: Skill Discovery Pass 1

> **Normal mode only** -- quick mode skips to Step 6 and never reaches this step. Quick mode gets its own Pass 1 in quick-mode.md.

Scan all skill files and match against the goal text:

1. Read each `${CLAUDE_PLUGIN_ROOT}/skills/*/SKILL.md` file's YAML frontmatter (`name`, `description` fields)
- If a SKILL.md is unreadable (file error, permissions): skip that skill, log warning
- If a SKILL.md has no `description` field in frontmatter: skip that skill, log "no description"
2. Determine **context text**: the goal text only (from Step 2)
3. Tokenize both context text and each skill's `description` using these rules:
a. Lowercase the entire string
b. Replace hyphens with spaces ("brainstorming-style" -> "brainstorming style")
c. Strip all punctuation (parentheses, commas, periods, colons, quotes, brackets, etc.)
d. Split on whitespace into word tokens
e. Remove stopwords: a, an, the, to, for, with, and, or, in, on, by, is, be, that, this, of, it, should, used, when, asks, needs, about
4. Count word overlap between context tokens and description tokens
5. If overlap >= 2 AND skill not already in `discoveredSkills` with `invoked: true`:
- Invoke: `Skill({ skill: "ralph-specum:<name>" })`
- On success: add `{ name, matchedAt: "start", invoked: true }` to `discoveredSkills`
- On failure: set `invoked: false` -- add `{ name, matchedAt: "start", invoked: false }`, log warning, continue
6. If no skills match across all scanned skills: log `- No skills matched`
7. Update `.ralph-state.json` with updated `discoveredSkills` array
8. Append a `## Skill Discovery` section to `.progress.md` with match details per skill:
```markdown
## Skill Discovery
- **<skill-name>**: matched (keywords: <overlapping words>)
- **<skill-name>**: no match
- **<skill-name>**: skipped (unreadable)
- **<skill-name>**: skipped (no description)
```
If no skills match: `- No skills matched`
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Pass 1 discoveries are overwritten by state initialization in the normal-mode New Flow.

The execution order is:

  1. Step 3 (Pass 1) — invokes skills, then tries to write discoveredSkills to .ralph-state.json (Step 3.7), but .ralph-state.json doesn't exist yet for a brand-new spec.
  2. New Flow step 7 — initializes .ralph-state.json from scratch with "discoveredSkills": [], silently discarding whatever Pass 1 recorded.
  3. New Flow step 12 (Pass 2) — reads discoveredSkills: [] (no Pass 1 records), bypassing deduplication and potentially re-invoking the same skills a second time.

This is in contrast to Quick Mode (quick-mode.md) which correctly initializes state before running Pass 1 (Step 5 → Step 9).

The root fix is to move Pass 1 to inside the New Flow, after state initialization (i.e., between current New Flow steps 7 and 8), matching the Quick Mode pattern. Alternatively, New Flow step 7 should explicitly merge rather than reset discoveredSkills if any were already accumulated.

Note: This bug only affects normal mode + new spec. Resume flow is unaffected since state already exists and is updated correctly at Step 3.7.

🛠️ Sketch of the fix (New Flow reordering)

Move the discovery block out of Step 3 and into the New Flow section:

-## Step 3: Skill Discovery Pass 1
-
-> **Normal mode only** -- quick mode skips to Step 6 and never reaches this step. Quick mode gets its own Pass 1 in quick-mode.md.
-
-[full Pass 1 instructions...]
-
 ## Step 4: Scan Existing Specs

Then inside "### New Flow", after the current step 7 (state init) and before step 8 (create .progress.md):

 7. Initialize `.ralph-state.json`:
    { ..., "discoveredSkills": [] }
+7a. **Skill Discovery Pass 1** -- scan skills, match against goal text, invoke matches
+    [full Pass 1 instructions, state write now safe since file was just created]
 8. Create `.progress.md` with goal

Also update the Quick Mode Check note in Step 2 accordingly.

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

In `@plugins/ralph-specum/commands/start.md` around lines 41 - 72, Pass 1
discovery results are being overwritten because New Flow initializes
.ralph-state.json after Step 3 writes discoveredSkills; move the Pass 1
discovery block so it runs after state initialization in the "New Flow" (i.e.,
run the skill discovery once the .ralph-state.json exists) or change the state
init to merge existing discoveredSkills instead of resetting them. Specifically,
relocate the Step 3 "Skill Discovery Pass 1" logic into the New Flow between
current step 7 (state init) and step 8 (create .progress.md) or modify the state
initialization to merge rather than replace discoveredSkills; ensure references
to .ralph-state.json and the discoveredSkills array are preserved and that
deduplication logic (checking invoked:true) still runs before invoking Skill({
skill: "ralph-specum:<name>" }).

Comment on lines +162 to +172
6. If no skills match across all scanned skills: log `- No skills matched`
7. Update `.ralph-state.json` with updated `discoveredSkills` array
8. Append a `### Post-Research Retry` subsection to `.progress.md` under `## Skill Discovery`:
```markdown
### Post-Research Retry
- **<skill-name>**: matched (keywords: <overlapping words>)
- **<skill-name>**: no match (already invoked)
- **<skill-name>**: skipped (unreadable)
- **<skill-name>**: skipped (no description)
```
If no new skills match: `- No new skills matched`
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Pass 2 "no match" log instruction disagrees with the template.

Line 162 instructs to log - No skills matched, but the progress template at line 172 shows - No new skills matched. The template wording is more appropriate for a second pass. Fix the inline instruction to match (same issue exists in quick-mode.md Step 12.6).

🛠️ Proposed fix
-    6. If no skills match across all scanned skills: log `- No skills matched`
+    6. If no new skills match across all scanned skills: log `- No new skills matched`
📝 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
6. If no skills match across all scanned skills: log `- No skills matched`
7. Update `.ralph-state.json` with updated `discoveredSkills` array
8. Append a `### Post-Research Retry` subsection to `.progress.md` under `## Skill Discovery`:
```markdown
### Post-Research Retry
- **<skill-name>**: matched (keywords: <overlapping words>)
- **<skill-name>**: no match (already invoked)
- **<skill-name>**: skipped (unreadable)
- **<skill-name>**: skipped (no description)
```
If no new skills match: `- No new skills matched`
6. If no new skills match across all scanned skills: log `- No new skills matched`
7. Update `.ralph-state.json` with updated `discoveredSkills` array
8. Append a `### Post-Research Retry` subsection to `.progress.md` under `## Skill Discovery`:
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@plugins/ralph-specum/commands/start.md` around lines 162 - 172, Update the
second-pass logging instruction so the wording matches the progress template:
change the inline log text `- No skills matched` to `- No new skills matched` in
plugins/ralph-specum/commands/start.md (the step describing Pass 2 and the
Appendix "Post-Research Retry") and apply the same change in quick-mode.md Step
12.6 so both the instruction and the `### Post-Research Retry` template use the
exact phrase `- No new skills matched`.

Comment on lines +147 to +157
6. If no skills match across all scanned skills: log `- No skills matched`
7. Update `.ralph-state.json` with updated `discoveredSkills` array
8. Append a `### Post-Research Retry` subsection to `.progress.md` under `## Skill Discovery`:
```markdown
### Post-Research Retry
- **<skill-name>**: matched (keywords: <overlapping words>)
- **<skill-name>**: no match (already invoked)
- **<skill-name>**: skipped (unreadable)
- **<skill-name>**: skipped (no description)
```
If no new skills match: `- No new skills matched`
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Pass 2 "no match" log message is inconsistent between the instruction and the template.

Line 147 says to log - No skills matched, but the markdown template at line 157 shows - No new skills matched. For Pass 2, the template wording is more accurate since skills may have matched in Pass 1. The same inconsistency exists in start.md Pass 2 (lines 162/172).

🛠️ Proposed fix
-6. If no skills match across all scanned skills: log `- No skills matched`
+6. If no new skills match across all scanned skills: log `- No new skills matched`
📝 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
6. If no skills match across all scanned skills: log `- No skills matched`
7. Update `.ralph-state.json` with updated `discoveredSkills` array
8. Append a `### Post-Research Retry` subsection to `.progress.md` under `## Skill Discovery`:
```markdown
### Post-Research Retry
- **<skill-name>**: matched (keywords: <overlapping words>)
- **<skill-name>**: no match (already invoked)
- **<skill-name>**: skipped (unreadable)
- **<skill-name>**: skipped (no description)
```
If no new skills match: `- No new skills matched`
6. If no new skills match across all scanned skills: log `- No new skills matched`
7. Update `.ralph-state.json` with updated `discoveredSkills` array
8. Append a `### Post-Research Retry` subsection to `.progress.md` under `## Skill Discovery`:
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@plugins/ralph-specum/references/quick-mode.md` around lines 147 - 157,
Summary: The "Pass 2" no-match log wording is inconsistent between the
instruction and the Post-Research Retry template; standardize on "No new skills
matched". Fix: update the Pass 2 log instruction that currently says "- No
skills matched" to read "- No new skills matched" wherever it appears in
quick-mode.md and start.md, and ensure the "### Post-Research Retry" subsection
template under "## Skill Discovery" uses the same phrase; verify any references
to the Pass 2 message in related docs/templates are updated to keep wording
consistent.


### Task 2.1 Completion
- Verified all 4 tokenization rule blocks are already word-for-word identical across start.md Pass 1 (line 51-56), start.md Pass 2 (line 151-156), quick-mode.md Pass 1 (line 105-110), quick-mode.md Pass 2 (line 136-141)
- Stopword list matches in all 4: a, an, the, to, for, with, and, or, in, on, by, is, be, that, this, of, it, should, used, when, asks, needs, about (25 words)
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Stopword count is off by two.

The list has 23 words, not 25. Purely a documentation nit with no functional impact.

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

In `@specs/smart-skill-swap-retry/.progress.md` at line 32, The stopword count in
the line starting "Stopword list matches in all 4: a, an, the, to, for, with,
and, or, in, on, by, is, be, that, this, of, it, should, used, when, asks,
needs, about (25 words)" is incorrect; update the parenthetical count to "(23
words)" (or recount and adjust if you intend to add/remove words) so the text
matches the actual list length.

- **Production TODOs**: If skill count grows beyond ~10, consider a centralized discovery reference file. For now, inline is simpler.
- **Key insight**: The "code" is markdown instructions for an AI agent. There is no runtime, no build, no test framework. "Testing" means structural validation of the markdown content.
- **Stopword list**: a, an, the, to, for, with, and, or, in, on, by, is, be, that, this, of, it, should, used, when, asks, needs, about (25 words)
- **Threshold**: 2 word overlap -- prevents false positives while catching real matches
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Grammar nit: hyphenate the compound modifier.

2 word overlap2-word overlap

🧰 Tools
🪛 LanguageTool

[grammar] ~346-~346: Use a hyphen to join words.
Context: ...eds, about (25 words) - Threshold: 2 word overlap -- prevents false positives...

(QB_NEW_EN_HYPHEN)

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

In `@specs/smart-skill-swap-retry/tasks.md` at line 346, Update the phrasing for
the Threshold line in specs/smart-skill-swap-retry/tasks.md by hyphenating the
compound modifier: change the phrase "**Threshold**: 2 word overlap" to
"**Threshold**: 2-word overlap" so the compound adjective is grammatically
correct.

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