Skip to content

Commit d7752cc

Browse files
committed
Step: Update /draft command with branching logic for initial drafting and review-driven refinement
1 parent 0de9f25 commit d7752cc

3 files changed

Lines changed: 44 additions & 21 deletions

File tree

.gemini/commands/draft.toml

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,49 @@
1-
description = "Interactive drafting workflow: gather context, create an outline based on the Style Guide, and generate a technical draft section-by-section."
1+
description = "Interactive drafting and refinement workflow: create a new technical draft from an outline or refine an existing one based on editorial feedback (.review.md)."
22

33
prompt = """
44
You are an expert technical writer. You are executing the custom `/draft` command workflow.
55
66
Follow these phases strictly:
77
8-
### Phase 1: Context Gathering
9-
1. **Analyze Request:** Identify the topic the user wants to draft.
8+
### Phase 1: Context & Mode Selection
9+
1. **Identify Topic/File:** Determine the topic the user wants to draft or the existing file they want to refine.
1010
2. **Search Context:** Search for existing context in `research/`, `plans/`, `TASKS.md`, and `journal/`. Use `list_directory` and `read_file`.
11-
3. **Read Style Guide:** Read the project's style guide at `.gemini/style-guide.md`.
12-
4. **Validate Context:** If no relevant research or planning context is found, use `ask_user` to suggest running `/research` or `/plan` first, or ask for more specific details.
11+
3. **Check for Review:** Search for a corresponding `<filename>.review.md` file for the target file.
12+
4. **Mode Branching:**
13+
- **Refinement Mode:** If a `.review.md` file exists, propose entering **Refinement Mode** to apply the suggested changes.
14+
- **Initial Drafting Mode:** If no review exists (or if the user explicitly wants to start fresh), follow the **Initial Drafting** workflow.
1315
14-
### Phase 2: Title and Path
15-
1. **Propose Metadata:** Based on the gathered context, propose a title for the document and a target file path (e.g., `drafts/your-title.md`).
16-
2. **Confirmation:** Use `ask_user` to get approval for the title and path.
16+
---
1717
18-
### Phase 3: Outline Creation (Style Guide Driven)
19-
1. **Generate Outline:** Based on the context and the rules in `.gemini/style-guide.md` (e.g., hooks, hierarchical headers, deep dives), generate a detailed Markdown outline.
20-
2. **Review Loop:** Present the outline to the user and ask for feedback or approval. Use `ask_user` to refine the outline until the user is satisfied.
18+
### [Initial Drafting Mode]
2119
22-
### Phase 4: Initialization
23-
1. **Create Skeleton:** Once the outline is approved, create the target file (if it doesn't exist) with the approved title and sections.
24-
2. **Placeholders:** Use placeholders like `<!-- [Section Name] Placeholder -->` for each section that needs to be filled.
20+
### Phase 2: Metadata & Outline
21+
1. **Propose Title/Path:** Suggest a title and file path (e.g., `drafts/your-title.md`). Confirm with `ask_user`.
22+
2. **Generate Outline:** Based on the Style Guide (`.gemini/style-guide.md`) and project context, create a detailed Markdown outline. Get user approval.
2523
26-
### Phase 5: Section-by-Section Drafting
27-
1. **Iterative Drafting:** For each section in the outline, invoke the `reporter` subagent.
28-
2. **Instructions:** Instruct the `reporter` to fill the specific placeholder with detailed, high-quality prose based on the gathered context. Ensure the `reporter` adheres to the general tone defined in the Style Guide.
29-
3. **Review Progress:** After each section is filled, briefly update the user on the progress.
24+
### Phase 3: Initialization & Expansion
25+
1. **Create Skeleton:** Create the target file with placeholders for each section.
26+
2. **Section-by-Section Drafting:** For each section, invoke the `writer` subagent to fill the placeholders with detailed prose that adheres to the Style Guide.
3027
31-
### Phase 6: Conclusion
32-
1. **Final Summary:** Once all sections are filled, notify the user that the draft is complete.
33-
2. **Next Steps:** Suggest using the `/review` command to perform a non-destructive, multi-phase audit of the new draft and produce a `<filename>.review.md` report. Mention that they can then use `/draft` again attaching the review to apply the changes.
28+
---
29+
30+
### [Refinement Mode]
31+
32+
### Phase 2: Review Analysis
33+
1. **Read Review:** Read the target file and its `.review.md` sidecar.
34+
2. **Identify Tasks:** Analyze the Structural, Substance, and Linguistic findings in the review.
35+
3. **Propose Refinement Plan:** Use `ask_user` to present a plan for applying the changes (e.g., "I will first fix the narrative arc, then address the abstract nouns in Section 2").
36+
37+
### Phase 3: Direct Refinement
38+
1. **Invoke Writer:** Invoke the `writer` subagent for each set of identified improvements.
39+
2. **Surgical Application:** Instruct the `writer` to use the `replace` tool to apply the improvements directly to the target file.
40+
3. **Verification:** Briefly report progress to the user after each major refinement.
41+
42+
---
43+
44+
### Phase 4: Conclusion (Common)
45+
1. **Final Summary:** Notify the user that the draft is complete or has been refined.
46+
2. **Next Steps:** Suggest using the `/review` command to perform a fresh audit of the new or updated draft.
3447
3548
Do not skip any phases. Start with Phase 1.
3649
"""

journal/2026-03-23.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
[2026-03-23T05:51:31] - Mark /review command improvement as done and archive task.
88
[2026-03-23T06:00:12] - Plan and task for improving /draft command and evolve writer agent.
99
[2026-03-23T06:00:52] - Rename reporter agent to writer and update its definition for composition and refinement.
10+
[2026-03-23T06:01:22] - Update /draft command with branching logic for initial drafting and review-driven refinement.

tests/test_review_command.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ def test_writer_agent_has_replace():
5252
content = f.read()
5353
assert "replace" in content
5454

55+
def test_draft_command_is_multimode():
56+
with open(".gemini/commands/draft.toml", "r") as f:
57+
content = f.read()
58+
assert "Refinement" in content
59+
assert "Initial Drafting" in content
60+
assert "writer" in content
61+
assert "reporter" not in content
62+
5563
if __name__ == "__main__":
5664
# Simple manual runner for now
5765
try:
@@ -67,6 +75,7 @@ def test_writer_agent_has_replace():
6775
test_writer_agent_exists()
6876
test_reporter_agent_gone()
6977
test_writer_agent_has_replace()
78+
test_draft_command_is_multimode()
7079

7180
print("Tests Passed")
7281
except AssertionError as e:

0 commit comments

Comments
 (0)