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 fmtautomatically 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, andrulesblocks. - Comment toggle — Ctrl+/ toggles
#line comments. - Document icon — Custom SVG icon for
.butterfiles.
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
| Setting | Default | Description |
|---|---|---|
butter.compilerPath | "butter" | Path to the butter binary. Change this if the binary isn't on your PATH. |
butter.compileOnSave | false | Compile 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:
| Name | Extension | Use case |
|---|---|---|
prompt | .prompt.md | Default. Markdown spec for pasting into AI chat. |
json | .json | Structured data for AI agents and programs. |
yaml | .yaml | Human-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.