Skip to content

Commit 55b63b5

Browse files
authored
feat(cli): add asset system for commands, templates, hooks, and presets (#47)
Extend dev-workflows from a rule compiler to a complete AI workflow system. The new asset system supports slash commands, spec templates, editor hooks, and presets that bundle everything together. Running `devw init --preset spec-driven` now sets up a full spec-driven development workflow.
1 parent d3c50be commit 55b63b5

25 files changed

Lines changed: 1261 additions & 30 deletions

File tree

content/commands/build.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
name: build
3+
description: "Execute a plan step by step with verification"
4+
version: "0.1.0"
5+
tool: claude
6+
---
7+
You are a senior software engineer. Your job is to execute an implementation plan step by step.
8+
9+
Follow this process:
10+
11+
1. **Read the plan** provided by the user (a path to a plan file).
12+
13+
2. **For each step in the plan:**
14+
a. Announce which step you are starting
15+
b. Make the code changes described
16+
c. Run verification: tests, lint, and type checks
17+
d. If verification passes, create a commit with the message from the plan
18+
e. If verification fails, fix the issue before moving on
19+
20+
3. **Rules:**
21+
- Never skip a step
22+
- Never combine steps into one commit
23+
- Always run tests after each step
24+
- If a step is unclear, ask for clarification before proceeding
25+
- If a step fails after 3 attempts, stop and report the issue
26+
27+
4. **After completing all steps:**
28+
- Run the full test suite
29+
- Report a summary: steps completed, tests passing, any issues
30+
31+
Be methodical. Quality matters more than speed.

content/commands/learn.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
name: learn
3+
description: "Capture a lesson learned and add it as a project rule"
4+
version: "0.1.0"
5+
tool: claude
6+
---
7+
You are a knowledge capture assistant. Your job is to turn a lesson learned (a mistake, a correction, or a best practice) into a permanent project rule.
8+
9+
Follow this process:
10+
11+
1. **Ask the user** what they learned. This could be:
12+
- A bug they found and how to avoid it
13+
- A pattern that works well in this codebase
14+
- A convention the AI should always follow
15+
- A mistake the AI made that should not be repeated
16+
17+
2. **Formulate a clear, actionable rule** from the lesson. The rule should:
18+
- Be specific to this project
19+
- Be written as an imperative instruction
20+
- Include context about why it matters
21+
- Be concise (1-3 sentences)
22+
23+
3. **Append the rule** to the project's `CLAUDE.md` file (or equivalent) under a `## Lessons Learned` section. If the section does not exist, create it.
24+
25+
Format:
26+
```
27+
## Lessons Learned
28+
29+
- <Rule description>. Context: <why this matters>.
30+
```
31+
32+
Confirm with the user before writing.

content/commands/plan.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
name: plan
3+
description: "Generate an implementation plan from a spec"
4+
version: "0.1.0"
5+
tool: claude
6+
---
7+
You are a senior software architect. Your job is to create a step-by-step implementation plan from a feature specification.
8+
9+
Follow this process:
10+
11+
1. **Read the spec** provided by the user (a path to a spec file in `docs/specs/`).
12+
13+
2. **Analyze the codebase** to understand:
14+
- Which files need to be created or modified
15+
- Existing patterns to follow
16+
- Dependencies and potential conflicts
17+
- Test infrastructure
18+
19+
3. **Generate the plan** with incremental, commit-ready chunks. Each step should:
20+
- Be independently testable
21+
- Build on the previous step
22+
- Include specific file paths and function names
23+
- Note what tests to write or update
24+
25+
Use this format:
26+
27+
```markdown
28+
# Plan: <feature-name>
29+
30+
**Spec:** <path-to-spec>
31+
**Estimated steps:** N
32+
33+
## Step 1: <title>
34+
**Files:** `path/to/file.ts`
35+
**Changes:**
36+
- Description of change 1
37+
- Description of change 2
38+
**Tests:** Description of tests to add
39+
**Commit message:** `type: description`
40+
41+
## Step 2: <title>
42+
...
43+
```
44+
45+
Each step should be small enough to review in one sitting. Prefer many small steps over few large ones.

content/commands/spec.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
name: spec
3+
description: "Generate a feature specification through guided questions"
4+
version: "0.1.0"
5+
tool: claude
6+
---
7+
You are a senior software architect. Your job is to create a clear, complete specification for a new feature.
8+
9+
Follow this process:
10+
11+
1. **Ask 3-5 clarifying questions** about the feature. Focus on:
12+
- What problem does this solve?
13+
- Who is the target user?
14+
- What are the key constraints (performance, compatibility, etc.)?
15+
- What does success look like?
16+
17+
2. **Research the codebase** before writing. Look at:
18+
- Existing patterns and conventions
19+
- Related features that already exist
20+
- Technology stack and dependencies
21+
22+
3. **Generate the spec** in `docs/specs/<feature-name>.md` using this structure:
23+
24+
```markdown
25+
# Feature: <name>
26+
27+
## Summary
28+
One paragraph describing the feature and its purpose.
29+
30+
## Requirements
31+
- [ ] Requirement 1
32+
- [ ] Requirement 2
33+
34+
## Technical Constraints
35+
- Constraint 1
36+
- Constraint 2
37+
38+
## Edge Cases
39+
- Edge case 1
40+
- Edge case 2
41+
42+
## Acceptance Criteria
43+
- [ ] Criterion 1
44+
- [ ] Criterion 2
45+
```
46+
47+
Wait for the user to answer your questions before generating the spec. Do not make assumptions.

content/hooks/auto-format.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "auto-format",
3+
"description": "Auto-format files after AI edits",
4+
"version": "0.1.0",
5+
"tool": "claude",
6+
"settings": {
7+
"hooks": {
8+
"PostToolUse": [
9+
{
10+
"matcher": "Write|Edit",
11+
"command": "pnpm format || true"
12+
}
13+
]
14+
}
15+
}
16+
}

content/presets/spec-driven.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: spec-driven
2+
description: "Complete spec-driven AI development workflow"
3+
version: "0.1.0"
4+
includes:
5+
rules:
6+
- workflow/spec-driven
7+
commands:
8+
- spec
9+
- plan
10+
- build
11+
- learn
12+
templates:
13+
- feature-spec
14+
hooks:
15+
- auto-format
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
name: spec-driven
3+
description: "Spec-driven development workflow: spec, plan, build, ship"
4+
version: "0.1.0"
5+
scope: workflow
6+
tags: [workflow, spec-driven, methodology]
7+
---
8+
9+
## Feature Development
10+
11+
- Every new feature MUST start with a spec. Use `/spec <feature-name>` to generate one through guided questions. Never jump straight to code.
12+
- After the spec is approved, generate an implementation plan with `/plan docs/specs/<feature-name>.md`. The plan breaks work into commit-ready steps.
13+
- Execute the plan step by step with `/build <plan-path>`. Each step is verified with tests and committed independently.
14+
- When you learn something new (a mistake, a pattern, a convention), capture it with `/learn` so the knowledge persists.
15+
16+
## Quality Gates
17+
18+
- Never skip the spec phase for features that touch more than 3 files. Small fixes and typos can go directly to implementation.
19+
- Every plan step must include what tests to write or update. No step is complete without passing verification.
20+
- If a step fails verification after 3 attempts, stop and ask for human guidance instead of forcing a solution.
21+
22+
## Specs
23+
24+
- Specs live in `docs/specs/` and follow the feature-spec template. Keep them concise but complete.
25+
- A good spec answers: what problem, for whom, what constraints, what success looks like, and what is explicitly out of scope.
26+
- Update the spec if requirements change during implementation. The spec is the source of truth.

content/templates/feature-spec.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
name: feature-spec
3+
description: "Template for writing feature specifications"
4+
version: "0.1.0"
5+
output_path: docs/specs
6+
---
7+
# Feature: [Feature Name]
8+
9+
## Summary
10+
11+
[One paragraph describing the feature, its purpose, and the problem it solves.]
12+
13+
## Requirements
14+
15+
- [ ] [Requirement 1]
16+
- [ ] [Requirement 2]
17+
- [ ] [Requirement 3]
18+
19+
## Technical Constraints
20+
21+
- [Constraint 1: e.g., must work with existing auth system]
22+
- [Constraint 2: e.g., response time under 200ms]
23+
24+
## Edge Cases
25+
26+
- [Edge case 1: e.g., what happens when input is empty?]
27+
- [Edge case 2: e.g., what happens with concurrent requests?]
28+
29+
## Acceptance Criteria
30+
31+
- [ ] [Criterion 1: measurable, testable outcome]
32+
- [ ] [Criterion 2: measurable, testable outcome]
33+
- [ ] [Criterion 3: measurable, testable outcome]
34+
35+
## Out of Scope
36+
37+
- [Thing explicitly not included in this feature]
38+
39+
## Open Questions
40+
41+
- [Question that needs to be resolved before implementation]

packages/cli/src/bridges/types.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,22 @@ export interface ProjectConfig {
2525
mode: 'copy' | 'link';
2626
blocks: string[];
2727
pulled: PulledEntry[];
28+
assets: AssetEntry[];
29+
}
30+
31+
export const ASSET_TYPE = {
32+
Command: 'command',
33+
Template: 'template',
34+
Hook: 'hook',
35+
} as const;
36+
37+
export type AssetType = typeof ASSET_TYPE[keyof typeof ASSET_TYPE];
38+
39+
export interface AssetEntry {
40+
type: AssetType;
41+
name: string;
42+
version: string;
43+
installed_at: string;
2844
}
2945

3046
export interface Bridge {

0 commit comments

Comments
 (0)