@rijalpermana/spec-forge 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +173 -0
- package/dist/cli.js +7540 -0
- package/package.json +41 -0
- package/templates/api-contract.md +7 -0
- package/templates/brief.md +21 -0
- package/templates/codebase.md +32 -0
- package/templates/prd.md +29 -0
- package/templates/schema.dbml +10 -0
- package/templates/tasks.md +11 -0
- package/templates/testcases.md +5 -0
package/README.md
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
# forge
|
|
2
|
+
|
|
3
|
+
Spec-driven development CLI. Scaffolds specs, DBML schemas, API contracts,
|
|
4
|
+
task lists, and test cases in a fixed folder structure, and bridges the same
|
|
5
|
+
workflow into whichever AI coding tool you use.
|
|
6
|
+
|
|
7
|
+
## Contents
|
|
8
|
+
|
|
9
|
+
- [Design](#design)
|
|
10
|
+
- [Prerequisites](#prerequisites)
|
|
11
|
+
- [Install](#install)
|
|
12
|
+
- [Workflow](#workflow)
|
|
13
|
+
- [Spec index](#spec-index)
|
|
14
|
+
- [AI tool support](#ai-tool-support)
|
|
15
|
+
- [Command reference](#command-reference)
|
|
16
|
+
- [Output structure](#output-structure)
|
|
17
|
+
- [Templates](#templates)
|
|
18
|
+
- [Troubleshooting](#troubleshooting)
|
|
19
|
+
|
|
20
|
+
## Design
|
|
21
|
+
|
|
22
|
+
- **Deterministic scaffolding lives in the CLI.** `forge` never calls an AI
|
|
23
|
+
model itself — no API key to manage, works offline, fast, free.
|
|
24
|
+
- **AI drafting happens wherever you already work** — Claude Code, Cursor,
|
|
25
|
+
Windsurf, or any other tool. Each generated file starts as a structured
|
|
26
|
+
stub with `[TODO]` markers; you (or the AI) fill it in, grounded in
|
|
27
|
+
`prd.md`.
|
|
28
|
+
- **Sequencing is enforced by guard rails, not convention.** `schema`,
|
|
29
|
+
`contract`, `tasks`, and `testcase` all refuse to run until `prd.md`
|
|
30
|
+
exists, so nothing gets invented without a spec behind it.
|
|
31
|
+
- **One instruction source, many renderers.** Every AI-tool bridge is
|
|
32
|
+
generated from `src/lib/command-specs.ts` — the instructions are written
|
|
33
|
+
once and rendered into each tool's native format, so they can't drift out
|
|
34
|
+
of sync with each other.
|
|
35
|
+
- **Nothing gets silently overwritten.** Spec files (`prd.md`, `schema.dbml`,
|
|
36
|
+
etc.) use `writeIfAbsent` — forge reports and stops if a file already
|
|
37
|
+
exists. Bridge files (`.claude/`, `.cursor/`, etc.) are regenerated freely
|
|
38
|
+
by design; re-run `forge bridge <target>` any time the command specs
|
|
39
|
+
change.
|
|
40
|
+
|
|
41
|
+
## Prerequisites
|
|
42
|
+
|
|
43
|
+
- [Bun](https://bun.sh) installed locally
|
|
44
|
+
- A project directory you want to scaffold specs into
|
|
45
|
+
|
|
46
|
+
## Install
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
cd forge
|
|
50
|
+
bun install
|
|
51
|
+
bun link # makes `forge` available globally on this machine
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Verify:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
forge --version
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Workflow
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
cd your-project
|
|
64
|
+
forge init # scaffolds specs/ + AI bridge (defaults to Claude Code)
|
|
65
|
+
forge scan # (optional) inventory existing code -> specs/CODEBASE.md
|
|
66
|
+
forge smelt btn-fraud-check # interactive Q&A -> brief.md + prd.md stub
|
|
67
|
+
|
|
68
|
+
# draft prd.md by hand, or with your AI tool, using brief.md as grounding
|
|
69
|
+
|
|
70
|
+
forge schema btn-fraud-check # schema.dbml (requires prd.md)
|
|
71
|
+
forge contract btn-fraud-check # api-contract.md (requires prd.md)
|
|
72
|
+
forge tasks btn-fraud-check # tasks.md (requires prd.md)
|
|
73
|
+
forge testcase btn-fraud-check # testcases.md (requires prd.md)
|
|
74
|
+
forge verify btn-fraud-check # reports missing files / unresolved [TODO]s
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Spec index
|
|
78
|
+
|
|
79
|
+
`forge init` creates `specs/INDEX.md` — a single manifest tracking every
|
|
80
|
+
feature's creation order, status, and dependencies, instead of encoding that
|
|
81
|
+
into folder names (which breaks under parallel branches — see design notes
|
|
82
|
+
below).
|
|
83
|
+
|
|
84
|
+
| Column | Set by | Meaning |
|
|
85
|
+
|---|---|---|
|
|
86
|
+
| `Feature` | `forge smelt` | Folder name under `specs/` |
|
|
87
|
+
| `Created` | `forge smelt` | Date first smelted; never changes after |
|
|
88
|
+
| `Status` | `forge smelt` (`draft`) → `forge verify` (`active` once complete) | Manually settable to `superseded` when a feature is replaced |
|
|
89
|
+
| `Depends On` | `forge smelt` prompt, or manual edit | Real dependency, not implied by folder order |
|
|
90
|
+
| `Notes` | Manual edit only | Free text — blockers, context, anything |
|
|
91
|
+
|
|
92
|
+
The manifest is **upserted, not overwritten** — `forge smelt`/`forge verify`
|
|
93
|
+
only ever touch the row for the feature they're operating on. Manual edits to
|
|
94
|
+
other rows' `Status`, `Depends On`, or `Notes` are preserved across runs.
|
|
95
|
+
|
|
96
|
+
## AI tool support
|
|
97
|
+
|
|
98
|
+
`forge init` defaults to a Claude Code bridge. Pick a different target with
|
|
99
|
+
`--target`, or generate additional bridges any time with `forge bridge
|
|
100
|
+
<target>`:
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
forge init --target cursor
|
|
104
|
+
forge bridge windsurf # add a second bridge to the same project
|
|
105
|
+
forge bridge generic # AGENTS.md fallback for any other tool
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
| Target | Files written | Invocation |
|
|
109
|
+
|---|---|---|
|
|
110
|
+
| `claude` | `.claude/commands/forge/*.md` | `/forge:smelt`, `/forge:schema`, ... |
|
|
111
|
+
| `cursor` | `.cursor/commands/forge-*.md` | `/forge-smelt`, `/forge-schema`, ... |
|
|
112
|
+
| `windsurf` | `.windsurf/workflows/forge-*.md` | `/forge-smelt`, `/forge-schema`, ... |
|
|
113
|
+
| `generic` | `AGENTS.md` (single file) | Point any AI tool at the file manually |
|
|
114
|
+
|
|
115
|
+
Claude Code uses frontmatter-driven shell execution (`!` command injection,
|
|
116
|
+
`$ARGUMENTS` substitution). Cursor and Windsurf commands are plain
|
|
117
|
+
instructions — their agents already have their own terminal tools, so the
|
|
118
|
+
bridge tells them which `forge` command to run rather than running it for
|
|
119
|
+
them. All four targets point at the same `prd.md`-grounding rules, so
|
|
120
|
+
drafting behavior stays consistent regardless of which tool actually does
|
|
121
|
+
the writing.
|
|
122
|
+
|
|
123
|
+
## Command reference
|
|
124
|
+
|
|
125
|
+
| Command | Requires | Produces | Overwrite-safe |
|
|
126
|
+
|---|---|---|---|
|
|
127
|
+
| `forge init [--target <t>]` | — | `specs/`, `specs/INDEX.md`, AI bridge files | Yes — bridge files regenerate freely |
|
|
128
|
+
| `forge bridge <target>` | — | AI bridge files for `<target>` | Yes — always regenerates |
|
|
129
|
+
| `forge scan [--depth <n>]` | — | `specs/CODEBASE.md` (stack, file stats, existing schema/API files, directory tree) | Yes — refreshes on every run |
|
|
130
|
+
| `forge smelt <feature>` | — | `brief.md`, `prd.md` (stub), `INDEX.md` entry (`draft`) | Yes — refuses if `brief.md` exists |
|
|
131
|
+
| `forge schema <feature>` | `prd.md` | `schema.dbml` (stub) | Yes |
|
|
132
|
+
| `forge contract <feature>` | `prd.md` | `api-contract.md` (stub) | Yes |
|
|
133
|
+
| `forge tasks <feature>` | `prd.md` | `tasks.md` (stub) | Yes |
|
|
134
|
+
| `forge testcase <feature>` | `prd.md` | `testcases.md` (stub) | Yes |
|
|
135
|
+
| `forge verify <feature>` | — | Console report, `INDEX.md` status → `active` if complete | N/A (read-only on spec files) |
|
|
136
|
+
|
|
137
|
+
## Output structure
|
|
138
|
+
|
|
139
|
+
```
|
|
140
|
+
your-project/
|
|
141
|
+
├── specs/
|
|
142
|
+
│ ├── INDEX.md # creation order, status, dependencies across all features
|
|
143
|
+
│ ├── CODEBASE.md # (optional) forge scan output: existing project inventory
|
|
144
|
+
│ └── <feature-name>/
|
|
145
|
+
│ ├── brief.md # smelt Q&A capture
|
|
146
|
+
│ ├── prd.md # goal, actors, user stories, business rules, out-of-scope
|
|
147
|
+
│ ├── schema.dbml # entities derived from prd.md
|
|
148
|
+
│ ├── api-contract.md # Title / endpoint / Request / Response / Note format
|
|
149
|
+
│ ├── tasks.md # WBS, sequenced data -> logic -> UI
|
|
150
|
+
│ └── testcases.md # No/Scenario/Case/Type/Expected/Actual/Status/Remark table
|
|
151
|
+
├── .claude/commands/forge/ # if target = claude
|
|
152
|
+
├── .cursor/commands/ # if target = cursor
|
|
153
|
+
├── .windsurf/workflows/ # if target = windsurf
|
|
154
|
+
└── AGENTS.md # if target = generic
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Templates
|
|
158
|
+
|
|
159
|
+
Edit anything in `templates/` to change the spec stub structure globally —
|
|
160
|
+
every future `forge schema`, `forge contract`, etc. call will use the
|
|
161
|
+
updated template. The `api-contract.md` and `testcases.md` templates are
|
|
162
|
+
locked to existing project formats; don't change their table columns without
|
|
163
|
+
also updating the matching instructions in `src/lib/command-specs.ts`, or
|
|
164
|
+
the templates and the AI-drafting instructions will drift out of sync.
|
|
165
|
+
|
|
166
|
+
## Troubleshooting
|
|
167
|
+
|
|
168
|
+
| Symptom | Cause | Fix |
|
|
169
|
+
|---|---|---|
|
|
170
|
+
| `forge: command not found` | `bun link` wasn't run, or shell hasn't reloaded | Re-run `bun link` in the `forge` package directory, restart your shell |
|
|
171
|
+
| `No prd.md found for "<feature>"` | Tried `schema`/`contract`/`tasks`/`testcase` before `smelt` | Run `forge smelt <feature>` first |
|
|
172
|
+
| `<file> already exists — skipping` | The output spec file is already there | Edit it directly, or delete it to regenerate from the template |
|
|
173
|
+
| `/forge:*` or `/forge-*` commands don't appear in your AI tool | `forge init`/`forge bridge` wasn't run for that target, or the tool needs a restart | Run `forge bridge <target>`, then restart the AI tool's session |
|