Add draftwise clarify [<feature>] — audit a product spec for gaps before drafting tech#65
Merged
Add draftwise clarify [<feature>] — audit a product spec for gaps before drafting tech#65
draftwise clarify [<feature>] — audit a product spec for gaps before drafting tech#65Conversation
…efore drafting tech
`draftwise clarify` reads `product-spec.md` and prints an instruction telling the host coding agent to audit it across four categories — ambiguities, untested assumptions, internal contradictions, and missing edge cases — present each issue with a specific line / section pointer, walk the PM through them one at a time (defer / reject / answer), then rewrite the file in place. The instruction explicitly tells the agent to preserve the YAML frontmatter (`depends_on` / `related`) and any sections the PM didn't touch, and to push back rather than rewrite if the answers expand scope ("that's a new spec, not a clarification").
Same shape as `tech` and `tasks`: auto-picks when one product spec exists; positional slug picks one when many; errors with the available list when ambiguous. Empty product spec errors with a hint to run `draftwise new` first. Routed through `COMMANDS` in `src/index.js`; sits between `new` and `tech` in the help output.
Why: drafted specs are uneven — some sections tight, others with hand-wavy acceptance criteria or untested assumptions buried in scope. Catching that *before* the technical spec is drafted means the engineering plan isn't built on a shaky foundation, and PMs don't have to re-litigate the same ambiguity in three files. Companion to `draftwise refine` (queued next): clarify is the upfront quality check, refine rewrites after PM edits.
Prompt at `src/ai/prompts/clarify.js`; command at `src/commands/clarify.js`. CLAUDE.md and README.md updated end-to-end.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a fourth drafting verb to the CLI that fits between
newandtech.draftwise clarifyreads an existingproduct-spec.mdand prints an instruction for the host coding agent to audit it for gaps, walk the PM through them, and rewrite the spec in place.The audit covers four categories:
Three-phase agent instruction: (1) read the spec end-to-end and surface 4-10 specific issues, each with a section/line pointer (skip the spec entirely if it's already tight); (2) walk the PM through them one-at-a-time, allowing defer / reject / answer; (3) rewrite the file in place — preserving YAML frontmatter and any sections the PM didn't touch. Hard rule built into the prompt: don't widen scope; if the PM's answer expands the feature, push back — that's a new spec, not a clarification.
Same auto-pick / multi-spec / unknown-slug ergonomics as
techandtasks. Errors when no.draftwise/dir exists, when no product specs exist, or when the spec file is empty.Why: drafted specs are uneven — some sections tight, others hand-wavy. Catching that before the technical spec gets drafted keeps the engineering plan from being built on a shaky foundation, and PMs don't have to re-litigate the same ambiguity in three files. Companion to a planned
draftwise refine(different problem: re-synthesize after PM edits).What changed
src/ai/prompts/clarify.jswithbuildAgentInstruction(slug)returning the three-phase instruction.src/commands/clarify.jsmirroringtech's shape (parseArgs, requireDraftwiseDir, listSpecs filter, auto-pick/positional/error paths).COMMANDSinsrc/index.js; help block now listsclarify [<feature>]betweennewandtech.test/commands/clarify.test.js(missing.draftwise/, no specs, auto-pick single, slug arg, multi-spec error, unknown slug error, empty product spec error, four-category audit instruction content, parseArgs strict mode).[Unreleased]### Added entry; CLAUDE.md and README.md updated.Test plan
npm test— 250 passingnpm run lint— cleandraftwise clarifyauto-picks; with two specs and no slug, it errors with the available list;draftwise clarify <missing>errors with the available list.