Skip to content

Add .draftwise/constitution.md — user-editable voice + spec-quality rules#63

Merged
4nkur merged 1 commit intomainfrom
feat/constitution
Apr 30, 2026
Merged

Add .draftwise/constitution.md — user-editable voice + spec-quality rules#63
4nkur merged 1 commit intomainfrom
feat/constitution

Conversation

@4nkur
Copy link
Copy Markdown
Owner

@4nkur 4nkur commented Apr 30, 2026

Summary

  • draftwise init writes .draftwise/constitution.md on both brownfield and greenfield paths. Five stable sections — Voice, Spec language, Edge case discipline, Project conventions, Domain glossary — that every drafting prompt (new, tech, tasks, scan, explain, greenfield Phase 3) instructs the host coding agent to read before drafting and apply by name.
  • Replaces the role src/ai/prompts/principles.js + src/ai/prompts/spec-quality.js used to play before the api-mode drop. Those modules injected rules into every system prompt; with synthesis moved entirely into the host coding agent, the rules now live in the user's repo as a markdown file the agent reads on each call. Editable, version-controlled, reviewable.
  • scan and greenfield Phase 3 also instruct the agent to refine the Project conventions section from observed code / chosen stack, replacing the placeholder text. Reader at src/utils/constitution.js returns null on ENOENT — every prompt says "skip silently if absent" so projects that ran init before this feature keep working.

Test plan

  • npx vitest run — 228 tests pass (10 new across test/utils/constitution.test.js + test/commands/init.test.js)
  • npm run lint clean
  • Manual: node bin/draftwise.js init --mode=brownfield in a temp repo confirms .draftwise/constitution.md is written and contains the five section headings
  • Manual: node bin/draftwise.js init --mode=greenfield --idea="…" in an empty dir confirms the same

… rules

`draftwise init` now writes `.draftwise/constitution.md` on both the brownfield and greenfield paths. Five stable section headings — Voice, Spec language, Edge case discipline, Project conventions, Domain glossary — that every drafting prompt (`new`, `tech`, `tasks`, `scan`, `explain`, greenfield Phase 3) tells the host coding agent to read before drafting and apply by name. `scan` and the greenfield Phase 3 additionally instruct the agent to refine the **Project conventions** section from observed code / chosen stack, replacing the placeholder.

This replaces the role that `src/ai/prompts/principles.js` and `src/ai/prompts/spec-quality.js` used to play before the api-mode drop. Those modules injected collaboration + spec-language rules into every system prompt; with synthesis moved entirely into the host coding agent, the rules now live in the user's repo as a markdown file the agent reads on each call. The file is user-editable and version-controlled, so changes are reviewable and travel with the repo.

Reader utility at `src/utils/constitution.js` (`readConstitution(cwd)` returns null on ENOENT, propagates other errors); template at `src/utils/constitution-template.js`. Every prompt that references the file says "skip silently if absent" — back-compat for projects that ran `init` before this feature landed.

CLAUDE.md and README.md updated end-to-end (key design principles, src/utils list, "What gets installed" tree). CHANGELOG.md `[Unreleased] ### Added` entry documents the rationale and the section structure.
@4nkur 4nkur merged commit da168f0 into main Apr 30, 2026
2 checks passed
@4nkur 4nkur deleted the feat/constitution branch April 30, 2026 04:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant