Skip to content

Commit 20ee073

Browse files
nhortonclaude
andcommitted
Add template agent support to create-agent skill
Allow seeding a new LearningAgent from an existing one by passing an optional template path. Copies core-knowledge.md, topics, and learnings from the template as a starting point, which the user can then customize. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 1a5cc56 commit 20ee073

File tree

2 files changed

+77
-8
lines changed

2 files changed

+77
-8
lines changed

learning_agents/scripts/create_agent.sh

Lines changed: 56 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
#!/bin/bash
22
# create_agent.sh - Create a new LearningAgent scaffold
33
#
4-
# Usage: create_agent.sh <agent-name>
4+
# Usage: create_agent.sh <agent-name> [template-agent-path]
5+
#
6+
# Arguments:
7+
# agent-name Name for the new agent (use dashes for multi-word)
8+
# template-agent-path Optional path to an existing learning agent directory
9+
# (e.g., .deepwork/learning-agents/my-existing-agent)
10+
# If provided, copies core-knowledge.md, topics/*, and
11+
# learnings/* from the template into the new agent.
512
#
613
# Creates:
714
# .deepwork/learning-agents/<agent-name>/core-knowledge.md
@@ -13,12 +20,25 @@
1320
set -euo pipefail
1421

1522
AGENT_NAME="${1:-}"
23+
TEMPLATE_PATH="${2:-}"
1624

1725
if [ -z "$AGENT_NAME" ]; then
18-
echo "Usage: create_agent.sh <agent-name>" >&2
26+
echo "Usage: create_agent.sh <agent-name> [template-agent-path]" >&2
1927
exit 1
2028
fi
2129

30+
# Validate template path if provided
31+
if [ -n "$TEMPLATE_PATH" ]; then
32+
if [ ! -d "$TEMPLATE_PATH" ]; then
33+
echo "Template agent directory not found: ${TEMPLATE_PATH}" >&2
34+
exit 1
35+
fi
36+
if [ ! -f "$TEMPLATE_PATH/core-knowledge.md" ]; then
37+
echo "Template directory missing core-knowledge.md: ${TEMPLATE_PATH}" >&2
38+
exit 1
39+
fi
40+
fi
41+
2242
AGENT_DIR=".deepwork/learning-agents/${AGENT_NAME}"
2343
CLAUDE_AGENT_FILE=".claude/agents/${AGENT_NAME}.md"
2444

@@ -55,8 +75,39 @@ These files let you customize how the learning cycle works for this agent. Each
5575
- **learning_from_issues.md** — Included during the `incorporate-learnings` step. Use this to guide how learnings are integrated — e.g., preferences for topics vs learnings, naming conventions, or areas of core-knowledge that should stay concise.
5676
ALG_README
5777

58-
# Create core-knowledge.md with TODO placeholder
59-
cat > "${AGENT_DIR}/core-knowledge.md" << 'CORE_KNOWLEDGE'
78+
# ========================================================================
79+
# SEED FROM TEMPLATE OR CREATE EMPTY
80+
# ========================================================================
81+
82+
if [ -n "$TEMPLATE_PATH" ]; then
83+
# Copy core-knowledge.md from template
84+
cp "$TEMPLATE_PATH/core-knowledge.md" "${AGENT_DIR}/core-knowledge.md"
85+
echo "Copied core-knowledge.md from template"
86+
87+
# Copy topics (if any exist beyond .gitkeep)
88+
TOPIC_COUNT=0
89+
for f in "$TEMPLATE_PATH/topics/"*.md; do
90+
[ -f "$f" ] || continue
91+
cp "$f" "${AGENT_DIR}/topics/"
92+
TOPIC_COUNT=$((TOPIC_COUNT + 1))
93+
done
94+
if [ "$TOPIC_COUNT" -gt 0 ]; then
95+
echo "Copied ${TOPIC_COUNT} topic(s) from template"
96+
fi
97+
98+
# Copy learnings (if any exist beyond .gitkeep)
99+
LEARNING_COUNT=0
100+
for f in "$TEMPLATE_PATH/learnings/"*.md; do
101+
[ -f "$f" ] || continue
102+
cp "$f" "${AGENT_DIR}/learnings/"
103+
LEARNING_COUNT=$((LEARNING_COUNT + 1))
104+
done
105+
if [ "$LEARNING_COUNT" -gt 0 ]; then
106+
echo "Copied ${LEARNING_COUNT} learning(s) from template"
107+
fi
108+
else
109+
# Create core-knowledge.md with TODO placeholder
110+
cat > "${AGENT_DIR}/core-knowledge.md" << 'CORE_KNOWLEDGE'
60111
TODO: Complete current knowledge of this domain.
61112
Written in second person ("You should...") because this text
62113
becomes the agent's system instructions. Structure it as:
@@ -66,6 +117,7 @@ becomes the agent's system instructions. Structure it as:
66117
4. Pitfalls to avoid
67118
5. Decision frameworks
68119
CORE_KNOWLEDGE
120+
fi
69121

70122
echo "Created agent directory: ${AGENT_DIR}"
71123
fi

learning_agents/skills/create-agent/SKILL.md

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,49 @@ Create a new LearningAgent and guide the user through initial configuration.
99

1010
## Arguments
1111

12-
`$ARGUMENTS` is the agent name. Use dashes for multi-word names (e.g., `rails-activejob`). If not provided, ask the user what to name the agent.
12+
`$ARGUMENTS` contains the agent name and an optional template path, separated by whitespace.
13+
14+
- **Agent name** (required): Use dashes for multi-word names (e.g., `rails-activejob`). If not provided, ask the user what to name the agent.
15+
- **Template agent path** (optional): Path to an existing learning agent directory (e.g., `.deepwork/learning-agents/my-existing-agent`). If provided, the new agent is seeded with the template's `core-knowledge.md`, `topics/`, and `learnings/` as a starting point. The user can then customize the copied content during configuration.
1316

1417
## Procedure
1518

1619
### Step 1: Validate and Run Scaffold Script
1720

21+
Parse `$ARGUMENTS` to extract the agent name (first word) and optional template path (second word, if present).
22+
1823
If the name contains spaces or uppercase letters, normalize to lowercase dashes (e.g., "Rails ActiveJob" → `rails-activejob`).
1924

2025
Check `.claude/agents/` for an existing file matching `<agent-name>.md`. If found, inform the user of the conflict and ask how to proceed.
2126

27+
If a template path was provided, verify it exists and contains `core-knowledge.md`. If not, inform the user and ask how to proceed.
28+
2229
Run the scaffold script:
2330

2431
```bash
25-
${CLAUDE_PLUGIN_ROOT}/scripts/create_agent.sh $ARGUMENTS
32+
# Without template:
33+
${CLAUDE_PLUGIN_ROOT}/scripts/create_agent.sh <agent-name>
34+
35+
# With template:
36+
${CLAUDE_PLUGIN_ROOT}/scripts/create_agent.sh <agent-name> <template-agent-path>
2637
```
2738

2839
If the script reports that directories already exist, inform the user and ask whether to proceed with updating the configuration or stop.
2940

41+
If a template was used, inform the user what was copied (the script output will list the counts).
42+
3043
### Step 2: Configure the Agent
3144

3245
Ask the user about the agent's domain:
3346

3447
- What domain or area of expertise does this agent cover?
3548
- What kinds of tasks will it be delegated to handle?
3649

50+
If a template was used, read the copied `core-knowledge.md` and present it to the user. Ask if they want to keep it as-is, modify it for the new agent's focus, or replace it entirely.
51+
3752
Based on their answers, update:
3853

39-
1. **`.deepwork/learning-agents/<agent-name>/core-knowledge.md`**: Replace the TODO content with the agent's core expertise in second person ("You should...", "You are an expert on...").
54+
1. **`.deepwork/learning-agents/<agent-name>/core-knowledge.md`**: If created from scratch, replace the TODO content with the agent's core expertise in second person ("You should...", "You are an expert on..."). If seeded from a template, adapt the content to reflect the new agent's specific focus area.
4055

4156
Example:
4257
```
@@ -52,7 +67,9 @@ Based on their answers, update:
5267

5368
### Step 3: Seed Initial Knowledge (Optional)
5469

55-
Ask the user if they want to seed any initial topics or learnings. If yes, create files using these formats:
70+
If a template was used and topics/learnings were copied, list what was copied and ask if the user wants to review, remove, or add to them.
71+
72+
Otherwise, ask the user if they want to seed any initial topics or learnings. If yes, create files using these formats:
5673

5774
**Topic file** (`.deepwork/learning-agents/<agent-name>/topics/<topic-name>.md`):
5875
```yaml

0 commit comments

Comments
 (0)