Skip to content

Commit fc40bfa

Browse files
danielkovclaude
andauthored
feat: granary workers (#4)
* feat: add granary worker * feat: daemon polish phase - logging, auth, pruning, process groups Implements Phase 5 daemon polish items: - File-based logging with tracing-subscriber and daily rotation - Worker pruning operation to clean up stopped/errored workers - Log streaming with follow support (has_more indicator) - IPC auth token authentication (auto-generated UUID, 0600 perms) - Log retention and rotation (7-day max age, 100 files per worker) - Process groups for clean process tree termination (setsid/kill -PID) New dependencies: tracing, tracing-subscriber, tracing-appender, libc Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: Windows build errors in daemon and CLI - Add Windows support to granaryd.rs with named pipes and Ctrl+C handling - Move Stdio import inside #[cfg(unix)] block in auto_start.rs - Add #[cfg_attr] to suppress unused variable warnings on Windows in run.rs Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: show blocked_by dependencies in task output Add blocked_by field to task output across all formatters (JSON, YAML, Markdown, Prompt, Table). This shows unmet task dependencies so agents can understand why tasks are blocked. Also update skill documentation to emphasize trusting the granary scheduler for parallelism decisions and using --format=prompt for LLM-friendly output. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * docs: add claude skills for commonly missed steps * feat: task/project.next * fix: migrate in sync + improve failure modes * fix: spawn runners in workspace dir --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 2920d99 commit fc40bfa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+14545
-74
lines changed

.claude-plugin/skills/initiative-planner/SKILL.md

Lines changed: 157 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,28 @@
11
---
22
name: granary-initiative-planner
3-
description: Plan and organize multi-project initiatives. Use when work spans multiple services, repositories, or has natural project boundaries.
3+
description: Plan and organize multi-project initiatives or significant, substantial projects. Use when work spans multiple services, repositories, or has natural project boundaries.
44
---
55

66
# Planning Multi-Project Initiatives
77

88
Use this skill when work naturally spans multiple projects or services. **Do NOT use for single-feature work**—use `/granary:plan-work` instead.
99

10-
**Your role:** High-level architecture, separation of concerns, dependency analysis, and spawning sub-agents for project planning. You do NOT plan individual project tasks yourself.
10+
**Your role:** High-level architecture, separation of concerns, dependency analysis, and spawning sub-agents for project planning. You do NOT plan individual project tasks yourself—you coordinate and synthesize.
11+
12+
## Your Focus as Initiative Planner
13+
14+
You are a **high-level coordinator**. Your job is to:
15+
16+
1. **Collect broad context** before any planning begins
17+
2. **Design the project structure** with clear boundaries
18+
3. **Spawn sub-agents** to handle detailed project planning
19+
4. **Synthesize cross-project dependencies** from sub-agent reports
20+
21+
**You do NOT:**
22+
23+
- Plan detailed tasks within projects (sub-agents do this)
24+
- Implement anything directly
25+
- Make low-level technical decisions
1126

1227
## When to Use Initiatives
1328

@@ -24,23 +39,55 @@ Use this skill when work naturally spans multiple projects or services. **Do NOT
2439
- There are no cross-project dependencies
2540
- It's a single feature in one service
2641

27-
## Step 1: Research and Assess
42+
## Step 1: Comprehensive Context Collection
43+
44+
**This is your most important step.** Before creating an initiative, gather broad context to inform the entire planning process. You are building the foundation that sub-agents will rely on.
2845

29-
Before creating an initiative, do high-level research to understand the scope:
46+
### 1.1 Search for Prior Art
3047

3148
```bash
32-
# Search for related existing work
49+
# Search granary for related existing work
3350
granary search "feature keywords"
3451
granary initiatives # Check existing initiatives
52+
granary projects # See all projects
53+
```
54+
55+
### 1.2 Understand Current Implementation
56+
57+
Research the codebase at a high level:
58+
59+
- What services/modules exist that will be affected?
60+
- What boundaries already exist in the architecture?
61+
- What shared dependencies or interfaces might be needed?
62+
- What are the current **limitations** of the system?
63+
64+
```bash
65+
# Example: understand existing architecture
66+
ls -la src/
67+
grep -r "mod " src/lib.rs
68+
cat README.md
3569
```
3670

37-
Research the codebase to understand:
71+
### 1.3 Gather External Context
3872

39-
- What services/modules exist that will be affected
40-
- What boundaries already exist in the architecture
41-
- What shared dependencies or interfaces might be needed
73+
**Use web search and documentation lookup** to understand:
4274

43-
**Decision tree:**
75+
- Industry best practices for similar features
76+
- Framework/library documentation for relevant technologies
77+
- Potential pitfalls or known issues others have encountered
78+
79+
This external research provides valuable context that sub-agents will benefit from when planning their projects.
80+
81+
### 1.4 Document Limitations and Constraints
82+
83+
Before proceeding, document:
84+
85+
- Technical limitations of the current system
86+
- Resource or time constraints
87+
- Dependencies on external systems or teams
88+
- Known risks or uncertainties
89+
90+
### 1.5 Decision Tree
4491

4592
| Situation | Action |
4693
| ------------------------------------------------- | ----------------------------------- |
@@ -144,23 +191,104 @@ Review the graph for:
144191

145192
## Step 7: Spawn Sub-Agents for Project Planning
146193

147-
**Do NOT plan project tasks yourself.** Spawn sub-agents to handle detailed project planning.
194+
**Do NOT plan project tasks yourself.** Spawn sub-agents to handle detailed project planning. Each sub-agent focuses deeply on one project while you maintain the high-level view.
148195

149-
For each unblocked project, spawn a sub-agent with `/granary:plan-work`:
196+
### 7.1 Get Projects Ready for Planning
150197

151198
```bash
152-
# Get unblocked projects
153-
granary initiative <initiative-id> next --all
199+
# Get all projects in the initiative
200+
granary initiative <initiative-id> projects
201+
202+
# Identify which projects are unblocked (no project dependencies)
203+
granary initiative <initiative-id> graph
154204
```
155205

156-
Then spawn sub-agents (using the Task tool) with prompts like:
206+
### 7.2 Spawn Sub-Agents with Large Context Models
207+
208+
**Critical:** Use the **largest context model available** (e.g., `claude-opus-4-5-20250101` or `opus`) for sub-agents. These planning tasks benefit from deep reasoning and extensive context windows.
157209

158-
> "Use /granary:plan-work to plan the project `auth-token-service-abc1`.
159-
> This project is part of the User Authentication System initiative.
160-
> It should implement JWT token generation and validation.
161-
> Create detailed tasks for implementation."
210+
For each unblocked project, spawn a sub-agent using the Task tool:
211+
212+
```
213+
Use Task tool with:
214+
prompt: [see template below]
215+
subagent_type: "general-purpose"
216+
model: "claude-opus-4-5-20250101" # Use largest available context model
217+
run_in_background: true # Spawn in parallel when multiple projects are unblocked
218+
```
162219

163-
Spawn agents for all unblocked projects in parallel when possible.
220+
### 7.3 Sub-Agent Prompt Template
221+
222+
Provide each sub-agent with:
223+
224+
1. **Project context** from your high-level research
225+
2. **Clear directive** to use `/granary:plan-work`
226+
3. **Instruction to report back** with cross-project dependencies
227+
228+
**Example prompt:**
229+
230+
```
231+
Use /granary:plan-work to plan the project `auth-token-service-abc1`.
232+
233+
## Context
234+
This project is part of the "User Authentication System" initiative.
235+
Goal: Implement JWT token generation and validation service.
236+
237+
## High-Level Context from Initiative Planning
238+
- The API will consume tokens via middleware (future project: api-auth-integration)
239+
- Token format should be JWT with RS256 signing
240+
- Existing auth patterns found in src/middleware/ use Bearer tokens
241+
- Reference: https://jwt.io/introduction for JWT best practices
242+
243+
## Your Task
244+
1. Research the project scope thoroughly
245+
2. Create detailed tasks with file paths, implementation details, and acceptance criteria
246+
3. Set up task dependencies within the project
247+
248+
## Required Report Back
249+
When planning is complete, summarize:
250+
1. **Tasks created** - List of tasks with brief descriptions
251+
2. **Cross-project interfaces** - What APIs, types, or contracts does this project expose that other projects will depend on?
252+
3. **Cross-project dependencies identified** - Did you discover dependencies on other initiative projects not yet captured?
253+
4. **Risks or blockers** - Any concerns that affect the broader initiative
254+
```
255+
256+
### 7.4 Spawn in Parallel
257+
258+
Spawn sub-agents for **all unblocked projects simultaneously**:
259+
260+
```
261+
# If projects A, B, C have no project dependencies, spawn all three at once:
262+
263+
Use Task tool (all in ONE message):
264+
1. prompt: [Project A planning prompt]
265+
model: "claude-opus-4-5-20250101"
266+
run_in_background: true
267+
268+
2. prompt: [Project B planning prompt]
269+
model: "claude-opus-4-5-20250101"
270+
run_in_background: true
271+
272+
3. prompt: [Project C planning prompt]
273+
model: "claude-opus-4-5-20250101"
274+
run_in_background: true
275+
```
276+
277+
### 7.5 Collect and Synthesize Reports
278+
279+
After sub-agents complete, review their reports for:
280+
281+
- **Cross-project dependencies** they identified (update initiative dependency graph if needed)
282+
- **Shared interfaces** that need coordination between projects
283+
- **Risks** that affect multiple projects
284+
285+
```bash
286+
# Update dependencies if sub-agents identified new ones
287+
granary project <project-B> deps add <project-A>
288+
289+
# Verify updated structure
290+
granary initiative <initiative-id> graph --format mermaid
291+
```
164292

165293
## Step 8: Hand Off to Orchestration
166294

@@ -215,14 +343,17 @@ granary initiative payment-processing-xyz1 summary
215343

216344
## Summary
217345

218-
1. **Research** -> Understand the codebase and architecture
346+
1. **Collect context broadly** -> Prior art, current implementation, limitations, external docs, web search
219347
2. **Assess** -> Is this truly multi-project work?
220-
3. **Create initiative** -> High-level container
348+
3. **Create initiative** -> High-level container with context documentation
221349
4. **Design separation** -> Clear boundaries, identify interfaces
222350
5. **Create projects** -> Add to initiative with good descriptions
223-
6. **Analyze dependencies** -> Review all project pairs, set dependencies
351+
6. **Analyze dependencies** -> Review all project pairs, set project-level dependencies
224352
7. **Verify structure** -> Check graph for issues
225-
8. **Spawn sub-agents** -> Each unblocked project gets a planning agent
226-
9. **Hand off** -> Orchestrator uses initiative-level commands
353+
8. **Spawn sub-agents** -> Use **largest context model** (opus), provide context, request cross-project dependency reports
354+
9. **Synthesize reports** -> Update dependencies based on sub-agent findings
355+
10. **Hand off** -> Orchestrator uses initiative-level commands
356+
357+
**Your output:** A well-structured initiative with projects and dependencies. Sub-agents handle detailed task planning within each project and report back cross-project dependencies they discover.
227358

228-
**Your output:** A well-structured initiative with projects and dependencies. Sub-agents handle detailed task planning within each project.
359+
**Key principle:** You are a high-level coordinator. Gather broad context, design the structure, delegate deep planning to sub-agents, then synthesize their findings.

0 commit comments

Comments
 (0)