Generate coding contracts that capture engineering knowledge as persistent,
language-agnostic artifacts. A contract defines WHAT to build and WHAT
CONSTRAINTS to respect, but never HOW to implement it. Any developer or
AI agent, in any language, can implement the same contract and produce
functionally equivalent code.
Produce spec.md files containing interface definitions, behavioral
constraints, and verification checklists — never complete implementations.
Never write function bodies, class implementations, configuration files,
or executable scripts. The implementer writes the code; you write the contract.
(Section 4). If you think "this is obvious", write it anyway. The
implementer may not share your assumptions.
at least one test case MUST exist in Section 5. Untested interfaces are
unspecified interfaces.
(e.g., [TIMEOUT_MS], [MAX_RETRY_COUNT]) or explain where the value
comes from (e.g., "configured via environment variable"). Never embed
literal numbers without context.
the Self-Validation Checklist below. Fix gaps before presenting.
backend, frontend, embedded, ML, data pipelines. Do not assume a specific
tech stack unless the user provides one.
Determine the input mode:
Mode A — Brainstorming Document Available:
If the user provides a design document from a brainstorming session, read it
carefully. Extract: feature scope, module boundaries, tech stack preferences,
data models, and user-approved decisions. Proceed to Phase 2.
Mode B — Raw Requirement (No Prior Design):
If the user provides only a natural language description, conduct a structured
clarification dialog. Ask as many questions as needed — there is no limit.
Goal: resolve all ambiguity before writing a single line of spec.
Clarification topics to cover (ask selectively based on context):
external API clients?
compliance needs?
retry, notify?
requirements?
Continue asking until the user confirms the picture is complete. Better to
over-communicate than to guess.
Read relevant existing code if available:
explicitly requested
If no existing codebase (greenfield), establish default conventions based on
industry best practices for the chosen tech stack. Document these decisions in
Section 6.
Write the spec following the structure in references/spec-template.md.
Key generation rules:
"IN: ... OUT: ..." format.
gets a one-sentence responsibility description. Arrows show dependencies.
// implementation left to implementerreferences/constraint-patterns.md for common patterns.- [ ]) for trackabilityBefore output, verify:
— replace with precise definitions
If any check fails, revise the spec and re-validate.
Output the complete spec as a file named spec.md. Prefix with:
<!-- Generated by coding-contract skill -->
<!-- This is a coding contract — interface signatures and constraints only, not implementation code -->
<!-- Implementer: fill in all [PLACEHOLDER] values before coding -->
Save the file. Do not proceed to implementation unless explicitly asked.
Default: docs/specs/YYYY-MM-DD-
Override: If the user specifies a location, use theirs.
references/spec-template.md for the completespec.md format with annotated examples.
references/constraint-patterns.md when writingSection 4 to ensure comprehensive coverage.
共 1 个版本