Butter logo

VS Code Extension

Syntax highlighting, auto-formatting, linting, and code completion for .butter files.

  • IntelliSense — Context-aware autocomplete for keywords, types, and block-level suggestions.
  • Syntax highlighting — Full TextMate grammar with named captures for all Butter keywords.
  • On-save formatting — Runs butter fmt automatically on every save.
  • On-save linting — Validates syntax with butter compile --check, shows errors as red squiggles.
  • Auto-indentation — Smart indent for feature, endpoint, params, actions, responses, returns, and rules blocks.
  • Comment toggleCtrl+/ toggles # line comments.
  • Document icon — Custom SVG icon for .butter files.

Installation

# Via install script
./install.sh extension

# Manually
code --install-extension butter-extension.vsix

# Or open butter-extension/ in VS Code and press F5

Settings

SettingDefaultDescription
butter.compilerPath"butter"Path to the butter binary. Change this if the binary isn't on your PATH.
butter.compileOnSavefalseCompile the spec on save and write generated outputs next to the source file.
butter.compileFormats["prompt"]Output formats generated on save when butter.compileOnSave is enabled. Supported: prompt, json, yaml.

Output Extensions

Butter's output formats are pluggable. Built-in formats:

NameExtensionUse case
prompt.prompt.mdDefault. Markdown spec for pasting into AI chat.
json.jsonStructured data for AI agents and programs.
yaml.yamlHuman-readable config and documentation.

Select with --format / -f. Prompt is the default.

Writing Output Extensions

Adding a new output format is a single Go file. Implement three methods:

package toml

import (
    "butter/pkg/ast"
    "butter/pkg/output"
)

func init() { output.Register(tomlExt{}) }

type tomlExt struct{}

func (tomlExt) Name() string          { return "toml" }
func (tomlExt) FileExtension() string { return ".toml" }
func (tomlExt) Serialize(spec *ast.AppSpec) ([]byte, error) {
    // your serialization logic
}

Then add a blank import to cmd/root.go and rebuild. The extension appears in --format help automatically.

The Serialize method receives a validated *ast.AppSpec with full access to spec.App, spec.Features, spec.Endpoints, params, actions, responses, returns, and enforce rules.