Module: Clacky::Agent::SkillReflector

Included in:
Clacky::Agent
Defined in:
lib/clacky/agent/skill_reflector.rb

Overview

Scenario 2: Reflect on skill execution and suggest improvements.

After a skill completes, inject a system prompt asking the LLM to analyze:

- Were instructions clear enough?
- Any missing edge cases?
- Any improvements needed?

If the LLM identifies concrete improvements, it can invoke skill-creator to update the skill.

Constant Summary collapse

MIN_SKILL_ITERATIONS =

Minimum iterations for a skill execution to warrant reflection. Raised to 5 to filter out lightweight skill invocations (e.g. platform management skills like cron-task-creator that the user triggered incidentally).

5

Instance Method Summary collapse

Instance Method Details

#maybe_reflect_on_skillObject

Check if we should reflect on the skill that just executed Called from SkillEvolution#run_skill_evolution_hooks



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/clacky/agent/skill_reflector.rb', line 22

def maybe_reflect_on_skill
  return unless @skill_execution_context

  # Only reflect on skills that the user explicitly invoked via slash command.
  # Skills triggered by the LLM itself (e.g. as part of a broader task) or
  # platform-management skills invoked incidentally should not be reflected on.
  return unless @skill_execution_context[:slash_command]

  skill_name = @skill_execution_context[:skill_name]
  start_iteration = @skill_execution_context[:start_iteration]
  iterations = @iterations - start_iteration

  # Only reflect if the skill actually ran for a meaningful number of iterations
  return if iterations < MIN_SKILL_ITERATIONS

  inject_skill_reflection_prompt(skill_name, iterations)

  # Clear the context so we don't reflect again
  @skill_execution_context = nil
end