Skip to content

feat(claude): auto-invoke learn skill after each task via stop hook#134

Merged
illeatmyhat merged 5 commits into
AgentToolkit:mainfrom
vinodmut:claudecodeplugin
Apr 3, 2026
Merged

feat(claude): auto-invoke learn skill after each task via stop hook#134
illeatmyhat merged 5 commits into
AgentToolkit:mainfrom
vinodmut:claudecodeplugin

Conversation

@vinodmut

@vinodmut vinodmut commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

For #132

Summary by CodeRabbit

Release Notes

  • New Features

    • Automatic learning runs after each task completion (manual learn remains available)
    • Skills renamed to the new evolve-lite namespace
  • Documentation

    • Updated docs for the new skill names and automatic learning flow
    • Added guidance on the automatic learning hook, its timeout/cost/delay implications, and how to disable or limit auto-learning

@coderabbitai

coderabbitai Bot commented Apr 2, 2026

Copy link
Copy Markdown

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Updated plugin docs and hooks to rename skills from the /evolve:* namespace to /evolve-lite:*, add an automatic Stop hook that triggers /evolve-lite:learn after each task (configurable/disableable), and add context: fork frontmatter to the recall and save skill declarations.

Changes

Cohort / File(s) Summary
Documentation
platform-integrations/claude/plugins/evolve-lite/README.md
Renamed documented skill namespace from /evolve:*/evolve-lite:*; documented auto-learning behavior via new Stop hook and how to disable/limit it.
Hook Configuration
platform-integrations/claude/plugins/evolve-lite/hooks/hooks.json
Added new top-level "Stop" hook group with empty matcher ("") that runs the evolve-lite:learn agent hook unless stop_hook_active is set; timeout set to 120 seconds.
Skill Metadata
platform-integrations/claude/plugins/evolve-lite/skills/recall/SKILL.md, platform-integrations/claude/plugins/evolve-lite/skills/save/SKILL.md
Added context: fork YAML frontmatter to recall and save skills.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant AgentRuntime as Agent Runtime (hooks)
  participant TaskRunner as Task Runner
  participant Claude as Claude (assistant)
  participant Skill as /evolve-lite:learn (skill)

  TaskRunner->>Claude: complete task
  Claude->>AgentRuntime: emit Stop hook (matcher="")
  AgentRuntime->>Skill: invoke /evolve-lite:learn (unless stop_hook_active)
  Skill-->>AgentRuntime: result / acknowledgment
  AgentRuntime-->>Claude: hook finished
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • visahak
  • gaodan-fang
  • illeatmyhat

Poem

🐰 I hop through docs with gentle might,
Renamed the skills to keep things light,
A Stop hook hums when tasks are done,
Learning springs up—one, two, fun! 🥕✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and specifically describes the main change: adding automatic invocation of the learn skill after each task using a stop hook mechanism.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

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

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

Inline comments:
In `@justfile`:
- Line 53: The justfile contains a wrong skill namespace in the claude
invocation: replace the path argument '/evolve:learn' with '/evolve-lite:learn'
so the command uses the correct skill (update the claude --plugin-dir ...
--continue -p '/evolve:learn' invocation to use '/evolve-lite:learn' instead) to
ensure learn=true triggers the intended /evolve-lite:learn skill.

In `@platform-integrations/claude/plugins/evolve-lite/lib/entity_io.py`:
- Around line 40-42: Change the flag path logic to derive session_id from the
JSON event on stdin instead of os.environ: read and parse JSON from stdin,
extract the "session_id" field (used in the current session_id variable) and use
that when building the flag filename with _get_log_dir(); if parsing fails or
the key is missing, fall back to the current os.getppid() behavior, and handle
JSON parse errors gracefully so the function that returns os.path.join(flag_dir,
f"auto-learn-{session_id}.flag") still always returns a valid path.

In
`@platform-integrations/claude/plugins/evolve-lite/skills/learn/scripts/auto_learn.py`:
- Around line 1-58: Run Ruff formatter on this file to satisfy CI: reformat
platform-integrations/claude/plugins/evolve-lite/skills/learn/scripts/auto_learn.py
(ensure imports, spacing, line lengths, and string concatenation follow project
Ruff rules). After running Ruff, confirm no lint failures remain for symbols in
this file such as the top-level functions main() and log(), the use of
auto_learn_flag_path(), and the JSON/stdin handling; commit the reformatted
file. Ensure the printed string concatenation and any trailing whitespace or
unused imports are fixed by Ruff before merging.
- Around line 37-45: Replace the non-atomic check-then-create sequence around
the "flag" in auto_learn.py with an atomic file creation using os.open(flag,
os.O_CREAT | os.O_EXCL | os.O_WRONLY) (or equivalent atomic API) so concurrent
processes cannot both succeed; catch the FileExistsError (or OSError with
EEXIST) to silently return when the flag already exists, and only on successful
creation write the file and call log("Flag created. Outputting learn
instruction."); remove the initial os.path.exists(flag) branch and use the
try/except around the atomic create to enforce idempotency for the flag variable
and the surrounding logic that calls log and returns.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: fcab9ccb-58b2-47cf-8675-06c826ce14a3

📥 Commits

Reviewing files that changed from the base of the PR and between 215704e and 05b124d.

📒 Files selected for processing (8)
  • justfile
  • platform-integrations/claude/plugins/evolve-lite/README.md
  • platform-integrations/claude/plugins/evolve-lite/hooks/hooks.json
  • platform-integrations/claude/plugins/evolve-lite/lib/entity_io.py
  • platform-integrations/claude/plugins/evolve-lite/skills/learn/scripts/auto_learn.py
  • platform-integrations/claude/plugins/evolve-lite/skills/recall/SKILL.md
  • platform-integrations/claude/plugins/evolve-lite/skills/recall/scripts/retrieve_entities.py
  • platform-integrations/claude/plugins/evolve-lite/skills/save/SKILL.md

Comment thread justfile Outdated
Comment thread platform-integrations/claude/plugins/evolve-lite/lib/entity_io.py Outdated
@vinodmut vinodmut changed the title feat(evolve-lite): auto-invoke learn skill after each task via stop hook feat(claude): auto-invoke learn skill after each task via stop hook Apr 2, 2026
@vinodmut vinodmut force-pushed the claudecodeplugin branch 2 times, most recently from 5925971 to 3ec8ce7 Compare April 2, 2026 18:29
Comment thread platform-integrations/claude/plugins/evolve-lite/README.md
@visahak

visahak commented Apr 3, 2026

Copy link
Copy Markdown
Collaborator

Resolved a conflict, please check the justfile content it was about both docker container run commands

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

🧹 Nitpick comments (2)
platform-integrations/claude/plugins/evolve-lite/README.md (2)

117-120: Consider documenting configuration for automatic learning behavior.

The Environment Variables section could be extended to include options for controlling the automatic learning behavior introduced by the Stop hook, such as:

  • Whether automatic learning can be disabled via an environment variable
  • Project-level configuration for the Stop hook behavior
  • Timeout configuration for the learn skill invocation

This would give users more control over the feature without requiring them to manually edit hooks.json.

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

In `@platform-integrations/claude/plugins/evolve-lite/README.md` around lines 117
- 120, Extend the Environment Variables section to document new config options
for automatic learning: add env vars like EVOLVE_AUTO_LEARN (true/false to
enable or disable automatic learning triggered by the Stop hook),
EVOLVE_LEARN_TIMEOUT (timeout in seconds for invoking the learn skill), and
EVOLVE_STOP_BEHAVIOR (e.g., "prompt"/"auto"/"skip" to control Stop hook
handling); also note that project-level overrides can be set in hooks.json by
adding a stopHook.learnAuto, stopHook.learnTimeout, and stopHook.behavior fields
and explain precedence (environment variables override hooks.json). Reference
EVOLVE_ENTITIES_DIR and CLAUDE_PROJECT_ROOT when explaining where
hooks.json/project-level settings are picked up so users know how to control
Stop -> learn behavior without editing core code.

8-8: Heading could be clearer about automatic-first behavior.

The heading "Manual Learning" might mislead users since learning is now automatic by default (via the Stop hook). The manual invocation is now a secondary capability. Consider renaming this to "Manual Invocation" or "On-Demand Learning" to better reflect that automatic learning is the primary mode.

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

In `@platform-integrations/claude/plugins/evolve-lite/README.md` at line 8, The
"Manual Learning" heading in the README is misleading because learning is
automatic by default via the Stop hook; rename the heading to "Manual
Invocation" or "On-Demand Learning" and update the description line that
references the `/evolve-lite:learn` skill to clarify it is a secondary,
on-demand capability (e.g., "Use the `/evolve-lite:learn` skill to manually
extract and save entities when needed; automatic extraction occurs by default
via the Stop hook"). Ensure the README mentions the Stop hook as the primary
automatic behavior and keeps the `/evolve-lite:learn` reference for manual use.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@platform-integrations/claude/plugins/evolve-lite/README.md`:
- Around line 38-47: Update the README to document UX impact and opt-out for the
automatic `/evolve-lite:learn` Stop hook: explain that the Stop hook with an
empty matcher ("") and a 120s timeout can add up to ~2 minutes delay after each
task and may run on every interaction, note potential resource/cost implications
of invoking `/evolve-lite:learn` frequently, and provide clear instructions for
disabling or limiting automatic learning (e.g., edit hooks.json to remove or
change the Stop hook, tighten the matcher string, or reduce the timeout) and
mention where learned entities are stored (`.evolve/entities/{type}/`) so users
can audit or remove saved data.

---

Nitpick comments:
In `@platform-integrations/claude/plugins/evolve-lite/README.md`:
- Around line 117-120: Extend the Environment Variables section to document new
config options for automatic learning: add env vars like EVOLVE_AUTO_LEARN
(true/false to enable or disable automatic learning triggered by the Stop hook),
EVOLVE_LEARN_TIMEOUT (timeout in seconds for invoking the learn skill), and
EVOLVE_STOP_BEHAVIOR (e.g., "prompt"/"auto"/"skip" to control Stop hook
handling); also note that project-level overrides can be set in hooks.json by
adding a stopHook.learnAuto, stopHook.learnTimeout, and stopHook.behavior fields
and explain precedence (environment variables override hooks.json). Reference
EVOLVE_ENTITIES_DIR and CLAUDE_PROJECT_ROOT when explaining where
hooks.json/project-level settings are picked up so users know how to control
Stop -> learn behavior without editing core code.
- Line 8: The "Manual Learning" heading in the README is misleading because
learning is automatic by default via the Stop hook; rename the heading to
"Manual Invocation" or "On-Demand Learning" and update the description line that
references the `/evolve-lite:learn` skill to clarify it is a secondary,
on-demand capability (e.g., "Use the `/evolve-lite:learn` skill to manually
extract and save entities when needed; automatic extraction occurs by default
via the Stop hook"). Ensure the README mentions the Stop hook as the primary
automatic behavior and keeps the `/evolve-lite:learn` reference for manual use.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: d26ca9d3-8652-4dac-a107-a1cda9342b9c

📥 Commits

Reviewing files that changed from the base of the PR and between 69d27c4 and 55d766d.

📒 Files selected for processing (6)
  • justfile
  • platform-integrations/claude/plugins/evolve-lite/README.md
  • platform-integrations/claude/plugins/evolve-lite/hooks/hooks.json
  • platform-integrations/claude/plugins/evolve-lite/skills/recall/SKILL.md
  • platform-integrations/claude/plugins/evolve-lite/skills/recall/scripts/retrieve_entities.py
  • platform-integrations/claude/plugins/evolve-lite/skills/save/SKILL.md
✅ Files skipped from review due to trivial changes (4)
  • platform-integrations/claude/plugins/evolve-lite/skills/save/SKILL.md
  • platform-integrations/claude/plugins/evolve-lite/skills/recall/scripts/retrieve_entities.py
  • platform-integrations/claude/plugins/evolve-lite/skills/recall/SKILL.md
  • justfile
🚧 Files skipped from review as they are similar to previous changes (1)
  • platform-integrations/claude/plugins/evolve-lite/hooks/hooks.json

Comment thread platform-integrations/claude/plugins/evolve-lite/README.md
visahak
visahak previously approved these changes Apr 3, 2026
@visahak

visahak commented Apr 3, 2026

Copy link
Copy Markdown
Collaborator

@vinodmut Can you please address the comments?

@vinodmut

vinodmut commented Apr 3, 2026

Copy link
Copy Markdown
Contributor Author

@visahak I addressed the comments and rebased. Can you please review again?

vinodmut added 5 commits April 3, 2026 10:34
The file-based flag system for once-per-turn learn triggering is no
longer needed. Removes auto_learn_flag_path() from entity_io, deletes
the unused auto_learn.py script, and removes flag clearing from
retrieve_entities.py.
Fixes failing CI check: check-formatting (3.12)
- Add stop_hook_active guard to prevent infinite loop when learn skill triggers another Stop event
- Simplify hook prompt wording
- Add missing trailing newline to hooks.json
- Remove spurious blank line in retrieve_entities.py
…hanism

Addresses CodeRabbit review finding: Document UX implications and opt-out mechanism
@illeatmyhat illeatmyhat merged commit 43c5951 into AgentToolkit:main Apr 3, 2026
16 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.

3 participants