Development-Driven Specs: Writing Documentation That Actually Works

Development-Driven Specs: Writing Documentation That Actually Works
Photo by RDNE Stock project on Pexels

Development-Driven Specs: Writing Documentation That Actually Works

A provocative post on Hacker News is challenging one of software engineering’s most sacred cows: the idea that specifications must come before code. The author of the Ensemble project argues forcefully for “development-driven specs”—writing documentation alongside or even after implementation, rather than before. For many IT professionals, this strikes a chord. We’ve all experienced the frustration of meticulously crafted specs that become outdated the moment development begins, or worse, specs that describe a system nobody actually wants to build.

This isn’t about abandoning documentation. It’s about recognizing that the best specifications emerge from understanding what you’re actually building, not guessing what you might build. Let’s explore how to make this approach work in practice, with concrete techniques you can apply immediately to your projects.

Table of Contents

Why Traditional Specs Fail in Practice

The waterfall promise was elegant: define everything upfront, then execute flawlessly. Reality proved messier. Requirements change when stakeholders see working software. Technical constraints emerge during implementation. Edge cases multiply like rabbits once you dig into the problem space.

Traditional spec-driven development creates a documentation debt problem. You write extensive specifications before understanding the problem deeply. Then development reveals the spec’s flaws. Now you face a choice: update the spec (time-consuming) or let it drift from reality (dangerous). Most teams choose the latter by default, creating a graveyard of outdated documents that new team members learn to distrust.

The irony? Teams often spend more time maintaining the fiction of accurate upfront specs than they would creating excellent documentation during development. Platforms like Coursera now offer entire courses on agile documentation practices that acknowledge this reality, teaching professionals how to maintain just enough specification to stay coordinated without drowning in premature detail.

The Development-Driven Approach

Development-driven specs flip the script. You build something small, learn from it, then document what you’ve learned. The specification becomes a reflection of working code, not a prediction of future code. This creates documentation with a critical property: accuracy.

Think of it like mapping territory you’ve already explored versus drawing maps of lands you’ve only imagined. The former will always be more accurate, more useful, more trusted by those who follow.

The Core Workflow

Start with a minimal design sketch—just enough to align on the problem and general approach. Build a vertical slice: one complete feature, end to end. As you build, document the actual decisions, interfaces, and constraints you discover. When the feature works, your documentation describes reality, not fantasy.

💡 Pro Tip: Keep a “decisions.md” file in your repository root. During code reviews, require that any non-obvious design choice gets a one-paragraph entry with the date and reasoning. This creates a living architectural decision record with zero overhead.

This approach works particularly well for APIs and system interfaces, where the contract between components matters more than internal implementation details. Let’s look at a concrete example of how to document an API using development-driven specs.

Practical Techniques for Documentation-During-Development

The best development-driven documentation emerges from tools and practices that extract specs directly from working code. Here are three techniques that work across languages and frameworks.

OpenAPI Specs from Implementation

Rather than writing an OpenAPI specification and trying to keep your REST API aligned with it, generate the spec from your implementation. Most modern frameworks support this pattern:

// Example using Go's swag library to generate OpenAPI from annotations
// Install: go install github.com/swaggo/swag/cmd/swag@latest

// @Summary Create a new user account
// @Description Creates a user with validation and returns the user ID
// @Tags users
// @Accept json
// @Produce json
// @Param user body UserCreateRequest true "User details"
// @Success 201 {object} UserCreateResponse
// @Failure 400 {object} ErrorResponse
// @Router /users [post]
func (h *Handler) CreateUser(w http.ResponseWriter, r *http.Request) {
    // Implementation here
}

// Generate spec with: swag init
// This creates docs/swagger.json from your annotated code

The beauty of this approach: your API documentation cannot drift from your actual endpoints. If the implementation changes, the spec regenerates to match. You’re documenting what exists, not what you hoped would exist six months ago.

Contract Testing as Living Specs

Contract tests serve double duty: they verify API behavior and document expected interactions. Tools like Pact create executable specifications that both producer and consumer teams can trust. For data-focused professionals looking to build similar documentation discipline around analytics pipelines, DataCamp offers practical courses on testing frameworks that treat data transformations with the same rigor as application code.

Code as Specification: API Contracts

Sometimes the code is the specification. Not the implementation—the interface. Type systems, particularly in languages with strong typing, create machine-verified contracts that never go stale.

// TypeScript interface as specification
// This defines exact behavior without implementation details

interface UserRepository {
  /**
   * Retrieves user by unique identifier.
   * @throws UserNotFoundError if ID doesn't exist
   * @throws DatabaseError if connection fails
   */
  getById(id: string): Promise<User>;

  /**
   * Creates new user. Email must be unique.
   * @returns Created user with generated ID and timestamps
   * @throws DuplicateEmailError if email already registered
   */
  create(userData: UserCreateParams): Promise<User>;
  
  /**
   * Soft deletes user (sets deletedAt timestamp).
   * Idempotent - deleting already-deleted user succeeds.
   */
  delete(id: string): Promise<void>;
}

// Any implementation MUST satisfy this contract
// IDE and compiler enforce the spec automatically

This interface is simultaneously documentation and enforcement mechanism. Future developers can’t accidentally violate the contract—the type checker won’t allow it. The spec lives in the codebase, versioned alongside implementation, impossible to separate or desynchronize.

⚠️ Common Mistake: Adding implementation details to interface documentation. Resist describing “how” in your interface specs—only describe “what” and “when.” The promise is behavior, not technique. This preserves implementation flexibility while maintaining clear contracts.

When Upfront Specs Actually Matter

Development-driven specs aren’t universal. Certain contexts demand more upfront specification work. Distributed teams building interdependent components need interface agreements before parallel development begins. Regulated industries require documented requirements for compliance. Hardware-software interfaces benefit from detailed specs since hardware changes are expensive.

The key distinction: specify interfaces and contracts upfront, not implementations. Define what components must do for each other, not how each accomplishes its internal work. A database API needs a clear contract; how that database achieves ACID properties internally can evolve.

The Hybrid Approach

Most real projects benefit from a hybrid strategy. Define high-level architecture and critical interfaces upfront—just enough for teams to work in parallel without stepping on each other. Then apply development-driven documentation within each component, capturing decisions and details as they emerge from implementation.

This gives you coordination without rigidity. Teams know where boundaries lie and what contracts they must honor, but retain freedom to adapt implementations as understanding deepens.

Making It Stick in Your Organization

Shifting to development-driven specs requires more than individual practice—it needs team buy-in. Start by identifying documentation pain points your team already feels. Are your API docs perpetually outdated? Do design documents gather dust while the code evolves? These frustrations create openings for change.

Propose a pilot: one project where specs emerge from development rather than preceding it. Choose a project with acceptable risk—not the critical authentication system, maybe an internal tool or new microservice. Track time spent on documentation under both approaches. Most teams find development-driven specs reduce total documentation effort while improving accuracy.

The cultural shift matters as much as the technical practices. Teams must embrace specifications as living artifacts, not immutable commandments. Code reviews should evaluate documentation changes alongside code changes. “Works but undocumented” and “documented but broken” both fail the same way—they breach the contract between present and future developers.

Stay in the loop — join 125,000+ IT professionals following Networkyy: Instagram · Facebook · Threads · Medium
🔥 RECOMMENDED FOR YOU

Master Modern Documentation Practices

Learn industry-proven techniques for creating technical documentation that developers actually use and trust, including API design, contract testing, and agile documentation workflows used by leading tech companies.

Start Learning on Coursera →

Scroll to Top