feat(claude): auto-invoke learn skill after each task via stop hook#134
Conversation
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughUpdated plugin docs and hooks to rename skills from the Changes
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
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (8)
justfileplatform-integrations/claude/plugins/evolve-lite/README.mdplatform-integrations/claude/plugins/evolve-lite/hooks/hooks.jsonplatform-integrations/claude/plugins/evolve-lite/lib/entity_io.pyplatform-integrations/claude/plugins/evolve-lite/skills/learn/scripts/auto_learn.pyplatform-integrations/claude/plugins/evolve-lite/skills/recall/SKILL.mdplatform-integrations/claude/plugins/evolve-lite/skills/recall/scripts/retrieve_entities.pyplatform-integrations/claude/plugins/evolve-lite/skills/save/SKILL.md
5925971 to
3ec8ce7
Compare
|
Resolved a conflict, please check the justfile content it was about both docker container run commands |
There was a problem hiding this comment.
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
📒 Files selected for processing (6)
justfileplatform-integrations/claude/plugins/evolve-lite/README.mdplatform-integrations/claude/plugins/evolve-lite/hooks/hooks.jsonplatform-integrations/claude/plugins/evolve-lite/skills/recall/SKILL.mdplatform-integrations/claude/plugins/evolve-lite/skills/recall/scripts/retrieve_entities.pyplatform-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
|
@vinodmut Can you please address the comments? |
55d766d to
7d07a32
Compare
|
@visahak I addressed the comments and rebased. Can you please review again? |
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
b3007b3 to
982794d
Compare
For #132
Summary by CodeRabbit
Release Notes
New Features
Documentation