Skip to content

Commit 290ac1b

Browse files
committed
Step: Implement /learn command definition
1 parent 1d41976 commit 290ac1b

6 files changed

Lines changed: 60 additions & 1 deletion

File tree

.gemini/commands/learn.toml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
description = "Explore and master a new library or topic, generating a permanent project skill."
2+
3+
prompt = """
4+
You are an expert learning agent. Follow this robust 6-phase workflow to explore and master the following topic: {{args}}
5+
6+
### Phase 1: Environment Audit
7+
1. **Identify Topic:** Determine the specific library, framework, or concept to be learned.
8+
2. **Check Presence:** Use shell commands (e.g., `pip show`, `npm list`, `go list`) to check if it's already installed.
9+
3. **Install if Missing:** If it's a library and not installed, ask the user for permission or use standard package managers to install it.
10+
11+
### Phase 2: Research & Mapping
12+
1. **Research Core Concepts:** Use `google_web_search` and `web_fetch` to identify the core API surface, common patterns, and architecture.
13+
2. **Survey Local Source:** Briefly survey local source files to identify existing usage or potential integration points.
14+
3. **Build Learning Map:** Create a structured "Learning Map" outlining what needs to be explored, including core features, edge cases, and common "gotchas."
15+
16+
### Phase 3: User Approval (Checkpoint)
17+
1. **Approval:** Use `ask_user` to present the "Learning Map" to the user for approval or modification. Do not proceed until approved.
18+
19+
### Phase 4: Grounded Experimentation
20+
1. **Invoke Generalist:** Use the `generalist` subagent to write and run small, independent test scripts (in Python, JS, etc.) to verify API behavior, performance, and specific use cases identified in the Learning Map.
21+
2. **Deep Dive:** Perform deep-dives into complex areas or potential "gotchas" through iterative experimentation.
22+
23+
### Phase 5: Skill Codification
24+
1. **Consult CLI Help:** Invoke the `cli_help` agent to understand the exact internal structure for a project skill.
25+
2. **Create Skill:** Create a new skill in `.gemini/skills/<skill-name>/SKILL.md`.
26+
3. **Populate Reference:** Add a comprehensive reference, idiomatic coding examples, and "gotchas" discovered during experimentation.
27+
4. **Reference Files:** If relevant, create additional `reference-*.md` subfiles for specialized use cases.
28+
29+
### Phase 6: Asset Management & Cleanup
30+
1. **Store Assets:** Move successful, high-value experiment scripts to the skill's assets folder (if appropriate) or link them in the documentation.
31+
2. **Cleanup:** Delete temporary experiment files and artifacts to keep the workspace clean.
32+
3. **Report:** Provide a final summary of what was learned and where the new skill is located.
33+
34+
Do not stop until the skill is fully codified and the workspace is clean.
35+
"""

TASKS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Put done tasks into the Archive.
1818

1919
## Active Tasks
2020

21-
- [ ] Implement the new `/learn` command and specialized learning agent to automate technology exploration and skill codification. (See plan: plans/implement-learn-command.md)
21+
- [/] In Progress (@gemini-cli) Implement the new `/learn` command and specialized learning agent to automate technology exploration and skill codification. (See plan: plans/implement-learn-command.md)
2222

2323
---
2424

journal/2026-03-20.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@
1515
[2026-03-20T10:19:25] - feat(docs): update install.sh to generate generic boilerplate for scaffolding files
1616
[2026-03-20T10:26:46] - chore(release): version 0.18.0
1717
[2026-03-20T12:01:05] - Plan and task created for /learn command implementation.
18+
[2026-03-20T12:03:54] - Implemented /learn command definition and verified with tests.

makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ all: test lint
44

55
test:
66
@echo "Running tests..."
7+
python3 -m unittest discover tests
78

89
docs-serve:
910
@mkdocs serve

tests/__init__.py

Whitespace-only changes.

tests/test_commands.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import os
2+
import tomllib
3+
import unittest
4+
5+
class TestCommands(unittest.TestCase):
6+
def test_learn_command_exists(self):
7+
path = ".gemini/commands/learn.toml"
8+
self.assertTrue(os.path.exists(path), f"{path} does not exist")
9+
10+
def test_learn_command_structure(self):
11+
path = ".gemini/commands/learn.toml"
12+
if not os.path.exists(path):
13+
self.skipTest("learn.toml does not exist yet")
14+
with open(path, "rb") as f:
15+
data = tomllib.load(f)
16+
self.assertIn("description", data)
17+
self.assertIn("prompt", data)
18+
self.assertGreater(len(data["description"]), 0)
19+
self.assertGreater(len(data["prompt"]), 0)
20+
21+
if __name__ == "__main__":
22+
unittest.main()

0 commit comments

Comments
 (0)