apistylespec

package module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 7, 2026 License: MIT Imports: 0 Imported by: 0

README

API Style Spec

Go CI Go Lint Go SAST Go Report Card Docs Docs Visualization License

Machine-readable API style specification format that generates human documentation, linting rules, LLM evaluation rubrics, and AI agent instructions from a single source of truth.

Overview

API style guides from Microsoft, Google, and Zalando have become industry standards, but they exist only as human-readable documents. api-style-spec creates a machine-readable specification format that serves as the canonical source, generating all artifacts from one definition.

api-style-spec (source of truth)
    ├── Human Style Guide (Markdown)
    ├── Deterministic Linters (Spectral/vacuum)
    ├── LLM Review Rubrics
    ├── AI Agent Instructions (Claude Code, Kiro)
    └── MCP Server Tools

Features

  • 📋 Unified Specification - Define rules once, generate all artifacts
  • Deterministic Linting - Fast, CI-friendly checks via vacuum
  • 🧠 LLM Evaluation - Semantic analysis for rules that can't be linted
  • 🏢 Industry Profiles - Pre-built profiles based on Microsoft, Google, Zalando guidelines
  • 🏆 Conformance Levels - Graduated compliance (bronze/silver/gold)
  • 🌐 Multi-Platform - CLI, Web UI, MCP server, AI agents

Installation

go install github.com/plexusone/api-style-spec/cmd/api-style@latest

Quick Start

# Lint an OpenAPI specification
api-style lint openapi.yaml

# Lint with a specific profile
api-style lint openapi.yaml --profile azure

# Lint multiple files with glob patterns
api-style lint api/*.yaml --recursive

# Watch mode for continuous linting
api-style lint openapi.yaml --watch

# Combined lint + LLM evaluation
api-style analyze openapi.yaml --profile azure --level silver

# Generate human-readable style guide
api-style generate guide --spec my-style.json --output docs/

Configuration

Create .api-style.yaml in your project root:

# .api-style.yaml
profile: azure
level: silver

include:
  - "openapi.yaml"
  - "**/api.yaml"

exclude:
  - "**/generated/**"

exceptions:
  - rule: URI-001
    paths: ["/legacy/**"]
    reason: "Legacy API cannot be changed"

severity-overrides:
  URI-002: warn

See .api-style.yaml.example for a complete example.

Specification Format

{
  "$schema": "https://api-style-spec.dev/schema/v1/api-style-spec.schema.json",
  "version": "1.0.0",
  "name": "my-api-style",
  "extends": ["default"],

  "rules": [
    {
      "id": "URI-001",
      "title": "Use plural resource names",
      "category": "uri-design",
      "severity": "error",
      "rationale": "Plural resources improve consistency.",
      "examples": {
        "good": ["/users", "/orders"],
        "bad": ["/user", "/order"]
      },
      "enforcement": {
        "type": "spectral",
        "function": "pattern",
        "options": {"match": "^/[a-z]+s(/|$)"}
      }
    }
  ]
}

CLI Commands

Command Description
api-style lint Deterministic linting (supports glob patterns, --watch, --recursive)
api-style evaluate LLM-based evaluation
api-style analyze Combined lint + evaluate
api-style generate guide Generate Markdown documentation
api-style generate spectral Generate Spectral ruleset
api-style hooks Generate AI assistant hooks
api-style hooks init Install git pre-commit hook
api-style diff Breaking change detection
api-style serve mcp Start MCP server
api-style serve web Start Web UI

Built-in Profiles

Profile Based On Rules
default Common best practices ~30
azure Microsoft/Azure guidelines ~80
google Google API Design Guide ~60
zalando Zalando RESTful Guidelines ~70

Documentation

License

MIT

Documentation

Overview

Package apistylespec provides a machine-readable API style specification format.

Index

Constants

View Source
const Version = "0.1.0-dev"

Version is the current version of api-style-spec.

Variables

This section is empty.

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis
cmd
api-style command
Command api-style is a CLI for API style specification linting and evaluation.
Command api-style is a CLI for API style specification linting and evaluation.
mcp-api-style command
mcp-api-style is an MCP server for API style specification linting and evaluation.
mcp-api-style is an MCP server for API style specification linting and evaluation.
schemagen command
Command schemagen generates JSON Schema from Go types.
Command schemagen generates JSON Schema from Go types.
pkg
analyze
Package analyze provides combined API style analysis.
Package analyze provides combined API style analysis.
config
Package config provides configuration file support for api-style-spec.
Package config provides configuration file support for api-style-spec.
files
Package files provides file resolution and pattern matching for OpenAPI specs.
Package files provides file resolution and pattern matching for OpenAPI specs.
generate
Package generate provides output generation from APIStyleSpec.
Package generate provides output generation from APIStyleSpec.
hooks
Package hooks provides integration with AI coding assistants via assistantkit.
Package hooks provides integration with AI coding assistants via assistantkit.
judge
Package judge provides LLM-as-Judge evaluation for API style rules.
Package judge provides LLM-as-Judge evaluation for API style rules.
lint
Package lint provides deterministic linting for OpenAPI specifications.
Package lint provides deterministic linting for OpenAPI specifications.
profile
Package profile provides loading and management of API style profiles.
Package profile provides loading and management of API style profiles.
sarif
Package sarif provides SARIF (Static Analysis Results Interchange Format) output for API style linting results.
Package sarif provides SARIF (Static Analysis Results Interchange Format) output for API style linting results.
types
Package types defines the core data types for api-style-spec.
Package types defines the core data types for api-style-spec.
watch
Package watch provides file watching for automatic re-linting.
Package watch provides file watching for automatic re-linting.
Package schema embeds JSON Schema files for runtime access.
Package schema embeds JSON Schema files for runtime access.
skills
apistyle
Package apistyle provides an omniskill Skill for API style specification linting and evaluation.
Package apistyle provides an omniskill Skill for API style specification linting and evaluation.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL