diff --git a/agent/learn_prompt.py b/agent/learn_prompt.py index b6659df6ad..7268b6b51c 100644 --- a/agent/learn_prompt.py +++ b/agent/learn_prompt.py @@ -201,10 +201,15 @@ def build_learn_prompt(user_request: str) -> str: "1b. Apply every requirement, focus, and constraint in the request to " "the skill you author — these govern what the SKILL.md covers and " "emphasizes, not just which sources you read.\n" - "2. Author the skill and save it with the `skill_manage` tool " - "(action=\"create\"). Pick a sensible category. If the procedure needs " - "a non-trivial script, add it under the skill's `scripts/` with " - "`skill_manage` write_file and reference it by relative path.\n" + "2. Save the skill with `skill_manage`. First check the available " + "skills for one covering this source or topic. If one exists, load it " + "with `skill_view`, then extend its SKILL.md with `skill_manage` patch " + "(or edit for a necessary full rewrite) and add or update supporting " + "files with `skill_manage` write_file. Only when no matching skill " + "exists, create one with `skill_manage` action=\"create\" and pick a " + "sensible category. If the procedure needs a non-trivial script, add " + "it under the skill's `scripts/` with `skill_manage` write_file and " + "reference it by relative path.\n" "2b. Pick the shape by the source, not by habit: a workflow or small " "source gets ONE tight SKILL.md; a book, paper stack, spec, or large " "docs corpus gets the knowledge-base layout below — a lean SKILL.md " diff --git a/tests/agent/test_learn_prompt.py b/tests/agent/test_learn_prompt.py index f42bff8994..45ed02f83b 100644 --- a/tests/agent/test_learn_prompt.py +++ b/tests/agent/test_learn_prompt.py @@ -94,6 +94,13 @@ class TestBuildLearnPrompt: assert "zero-width" in hyg assert "bidi" in hyg or "bidirectional" in hyg + def test_existing_skill_is_extended_instead_of_created_again(self): + prompt = build_learn_prompt("add these notes to my distributed-systems skill") + assert "First check the available skills" in prompt + assert "If one exists, load it with `skill_view`" in prompt + assert "Only when no matching skill exists" in prompt + assert 'action="create"' in prompt + class TestLearnRegistryWiring: def test_learn_is_registered_and_resolves(self):