Artifact first workflow

From UitbreidenOS/UitKit · View interactive version

Artifact first workflow is an AI agent skill from the GitHub repository UitbreidenOS/UitKit. Claude Code Artifact-First Workflow: single source of truth specifications. Draft, version, and edit specifications (SPEC.md) first, treating the actual codebase implementation as a compilable/generated output

How to use this skill

Skill file

Artifact-First Workflow — Specification-Driven Code Generation

When to activate

When NOT to use

Instructions

The Artifact-First Workflow reverses the traditional development model: the specification document (SPEC.md or a dedicated spec file under .claude/specs/) is the single source of truth, and the actual codebase is treated as a derivative output compiled from it.

       ┌───────────────────┐
       │   1. Spec File    │ ◄─────── Requirement Changes
       │     (SPEC.md)     │          (Edited by human/AI)
       └─────────┬─────────┘
                 │
                 ▼
       ┌───────────────────┐
       │ 2. Implementation │ ◄─────── Refactored / Generated
       │    (Code Files)   │          (Targeted by compilation)
       └─────────┬─────────┘
                 │
                 ▼
       ┌───────────────────┐
       │  3. Verification  │
       │   (Tests & CI)    │
       └───────────────────┘

1. Spec Artifact Structure

Every spec artifact must live in .claude/specs/[feature-name].md (or SPEC.md for single-purpose projects) and follow this template:

# Spec: [Feature Name]
**Version:** 1.0.0
**Last Updated:** 2026-06-17
**Status:** [Draft | Approved | Deprecated]

## 1. Goal
- [Measurable high-level business objective]

## 2. Architecture & Data Flow
- [Flow diagrams or structural descriptions]

## 3. Interface Design
- [API signatures, components, props, or database schema]

## 4. Invariants & Guardrails
- [Logical rules that must NEVER be violated under any circumstances]

## 5. Implementation Files
- [List of paths to files containing the concrete code]

## 6. Verification Criteria
- [Tested scenarios, input/output values, and execution steps]

2. The Development Loop

  1. Drafting the Spec: First, edit or create the Spec file. Describe what needs to be done, including schema, interfaces, invariants, and tests.
  2. User Review & Approval: Present the Spec to the user. Do not write a single line of code until the Spec is approved.
  3. Code Compilation: Read the approved Spec and generate or edit the target implementation files. Add a spec reference header to every source file:
  1. Verification: Run the tests matching the verification criteria.
  2. Refactoring Loop: If tests fail due to coding errors, fix the code. If tests reveal a design flaw or missing requirement, re-edit the Spec first, get approval, and then re-generate the code.

3. Benefits & Anti-Patterns


Example

Implementing a Token Vault Service using Artifact-First Workflow:

Step 1: Spec Created (`.claude/specs/token-vault.md`)

# Spec: Token Vault
**Version:** 1.1.0

## 3. Interface Design

interface TokenVault {

saveToken(id: string, token: string): Promise<void>;

getToken(id: string): Promise<string | null>;

}


## 4. Invariants
- Tokens must be encrypted using AES-256-GCM before database insertion.
- Raw unencrypted tokens must NEVER be logged to stdout or file logs.

Step 2: User Approves

User: "Looks good. Implement it."

Step 3: Code Compilation (`src/services/vault.ts`)

// Spec-Ref: .claude/specs/token-vault.md#v1.1.0
import crypto from 'crypto';

export class CryptVault implements TokenVault {
  // Implementation details following the spec invariants...
}

If requirements change (e.g., adding token expiry), the .claude/specs/token-vault.md is updated to v1.2.0 first, then src/services/vault.ts is regenerated and the header tag is updated.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.