This file provides quick, actionable guidance for AI coding agents working on the oastools project. For comprehensive details, see CLAUDE.md.
⚠️ BRANCH PROTECTION: Themainbranch has push protections. Before making ANY changes, verify you're on a feature branch (git branch --show-current). If on main, create a branch first:git checkout -b <type>/<description>
oastools is a Go-based CLI tool for working with OpenAPI Specification (OAS) files. It supports parsing, validating, fixing, joining, converting, and comparing OAS documents across versions 2.0, 3.0.x, 3.1.x, and 3.2.0.
Module: github.com/erraggy/oastools
Go Version: 1.25+
CRITICAL: Install golangci-lint v2 before making code changes:
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.1.0
export PATH=$PATH:$(go env GOPATH)/bin
golangci-lint version # Should show v2.1.0# Build and test workflow (run after every code change)
make check # Runs tidy, fmt, lint, test, and git status
# Individual commands
make build # Build binary to bin/oastools
make test # Run all tests with race detection
make test-coverage # Generate and view HTML coverage report
make fmt # Format all Go code
make lint # Run golangci-lint (requires v2 installation)
# Benchmarks
make bench # Run benchmarks
make bench-save # Save new benchmark baseline (only if changes affect performance)ALL exported functionality MUST have comprehensive tests:
- Positive cases (valid inputs work)
- Negative cases (errors handled correctly)
- Edge cases (nil, empty, boundary conditions)
- Integration cases (components work together)
Benchmark tests MUST use Go 1.24+ pattern:
func BenchmarkOperation(b *testing.B) {
// Setup
source, _ := parser.ParseWithOptions(...)
for b.Loop() { // ✅ Use b.Loop(), NOT for i := 0; i < b.N; i++
_, err := Operation(source)
if err != nil {
b.Fatal(err)
}
}
}Use package constants instead of string literals:
- HTTP Methods:
httputil.MethodGet,httputil.MethodPost, etc. - HTTP Status Codes:
httputil.ValidateStatusCode(),httputil.StandardHTTPStatusCodes - Severity Levels:
severity.SeverityError,severity.SeverityWarning, etc.
Format preservation:
- Parser, converter, and joiner preserve input file format (JSON or YAML)
- Format detected from file extension or content
- First file determines output format for joiner
Type handling in OAS 3.1+:
// schema.Type can be string or []string - always use type assertions
if typeStr, ok := schema.Type.(string); ok {
// Handle string type
} else if typeArr, ok := schema.Type.([]string); ok {
// Handle array type
}Pointer semantics:
// Use pointer slices for nested structures
servers := []*parser.Server{
&parser.Server{URL: "https://api.example.com"}, // ✅ Correct
}Size computation overflow (CWE-190):
capacity := 0
sum := uint64(len(a)) + uint64(len(b))
if sum <= uint64(math.MaxInt) {
capacity = int(sum)
}
result := make([]string, 0, capacity)Always check for vulnerabilities:
govulncheck ./....github/workflows/- CI/CD workflows (unless specifically requested)testdata/- Test fixtures (unless adding new test cases)vendor/,bin/,dist/- Generated artifactsgo.mod,go.sum- Only modify when explicitly adding/removing dependencies.goreleaser.yaml- Release configurationbenchmarks/- Benchmark data (see BENCHMARK_UPDATE_PROCESS.md)
A task is complete when:
- ✅ All required functionality is implemented
- ✅ New/modified exported functions have comprehensive tests
- ✅
make buildsucceeds without errors - ✅
make testpasses with no failures - ✅ Code is formatted and follows existing patterns
- ✅ Public APIs have godoc comments
- ✅ No regressions in existing tests
- ✅ No new security vulnerabilities (
govulncheck)
For documentation-only changes, only items 3, 6, and 7 apply.
Commit messages:
- First line: Conventional commit format (max 72 chars)
- Examples:
feat: add webhook support to parser,fix: handle nil pointer in converter
PR format:
- Title: Same as commit message
- Body: Detailed markdown explaining reasoning, changes, and context
- Type assertions: Don't assume
schema.Typeis always a string - check both string and []string - Pointer slices: Use
&Type{...}for pointer semantics, not value types - Conversion issues: Track all lossy conversions or unsupported features
- Deep copy: Never mutate source documents - use generated
DeepCopy()methods (e.g.,doc.DeepCopy()), never JSON marshal/unmarshal - Operation-level overrides: Check operation-level fields before falling back to document-level
- Version features: Explicitly handle version-specific features during conversion
cmd/oastools/ - CLI entry point
parser/ - Parse YAML/JSON OAS files, resolve refs
validator/ - Validate OAS against spec schema
fixer/ - Automatically fix common validation errors
converter/ - Convert between OAS versions
joiner/ - Join multiple OAS files
overlay/ - Apply OpenAPI Overlay transformations
differ/ - Compare and diff OAS files
generator/ - Generate Go code from OAS files
builder/ - Build OAS documents programmatically
httpvalidator/ - Runtime HTTP request/response validation
walker/ - Traverse OAS documents with typed handlers
oaserrors/ - Structured error types for programmatic handling
internal/ - Shared utilities (httputil, severity, issues, mcpserver)
testdata/ - Test fixtures
Each public package includes doc.go (package docs) and example_test.go (godoc examples).
Four specialized agents streamline the development workflow. They are automatically invoked based on context and can chain together.
| Agent | Purpose | Auto-triggers when |
|---|---|---|
| Architect | Design implementation plans | Starting features, planning refactors, architectural decisions |
| Maintainer | Code review & standards | After code changes, before commits, after Developer completes |
| Developer | Execute plans (checkpoint mode) | After Architect plans, implementation requests, bug fixes |
| DevOps Engineer | Process & tooling | Releases, CI/CD, benchmarks, dependencies |
User Request
│
▼
┌─────────────┐
│ Architect │ ← Plans the implementation
└──────┬──────┘
│
▼
┌─────────────┐
│ Developer │ ← Implements in phases with checkpoints
│ (pause) │ ──── User: "continue" ────┐
└──────┬──────┘ │
│ ◄────────────────────────────────┘
▼
┌─────────────┐
│ Maintainer │ ← Reviews changes
└──────┬──────┘
│
▼
┌─────────────┐
│ DevOps │ ← Prepares release (when needed)
└─────────────┘
The Developer agent pauses between implementation phases:
- Implements one phase
- Runs tests
- Shows changes summary
- Pauses for approval
- On "continue" → next phase
- After final phase → invokes Maintainer
| Level | Icon | Meaning |
|---|---|---|
| Critical | 🔴 | Must fix before merge (bugs, security, breaking changes) |
| Warning | 🟡 | Should fix (standards violations, missing tests) |
| Suggestion | 🔵 | Consider (style, optional improvements) |
Located in .claude/agents/:
architect.md- Planning and designmaintainer.md- Code review and standardsdeveloper.md- Implementation executiondevops-engineer.md- DevOps and tooling
- Full instructions: CLAUDE.md
- OAS 2.0 Spec: https://spec.openapis.org/oas/v2.0.html
- OAS 3.0 Spec: https://spec.openapis.org/oas/v3.0.0.html
- OAS 3.1 Spec: https://spec.openapis.org/oas/v3.1.0.html
- OAS 3.2 Spec: https://spec.openapis.org/oas/v3.2.0.html
- JSON Schema 2020-12: https://www.ietf.org/archive/id/draft-bhutton-json-schema-01.html