oastools
AGENTS.md7 starsChanged 9 months agoMITView on GitHub
This file provides quick, actionable guidance for AI coding agents working on the oastools project. For comprehensive details, see CLAUDE.md. ⚠️ BRANCH PROTECTION: The main branch 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,…
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 31,439 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository9 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- plugin/CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- corpus-testSkill
- gen-testSkill
- prepare-releaseSkill
- prereviewSkill
- publish-releaseSkill
- quality-gateSkill
The file
We split this AGENTS.md into the rules it gives an agent
5 rules. About 0 are common, 2 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 160
Type assertions: Don't assume schema.Type is always a string - read it through internal/schemautil
- Very specific: line 161
Pointer slices: Use &Type{...} for pointer semantics, not value types
- Very specific: line 163
Deep copy: Never mutate source documents - use generated DeepCopy() methods (e.g., doc.DeepCopy()), never JSON marshal/unmarshal
- Distinctive: line 164
Operation-level overrides: Check operation-level fields before falling back to document-level
- Distinctive: line 238
After final phase → invokes Maintainer
≈ “Common” is an estimate: at least 1 in 5 of the 40,246 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AGENTS.md
This file provides quick, actionable guidance for AI coding agents working on the oastools project. For comprehensive details, see CLAUDE.md.
⚠️ BRANCH PROTECTION: The
mainbranch 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>
Project Overview
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+
Dev Environment Setup
CRITICAL: Install the pinned golangci-lint before making code changes:
make lint-install
export PATH=$PATH:$(go env GOPATH)/binThe version lives in one place, GOLANGCI_VERSION in the Makefile, and CI reads
it from there. make lint refuses to run against any other version, because
findings would not match CI.
Quick Commands
# 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 cross-package coverage
make test-coverage # Generate and view HTML coverage report
make fmt # Format all Go code
make lint # Run golangci-lint (the version the Makefile pins)
# Benchmarks
make bench # Run benchmarks
make bench-save # Save new benchmark baseline (only if changes affect performance)Testing Requirements
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)
}
}
}Code Style & Patterns
Use package constants instead of string literals:
- HTTP Methods:
httputil.MethodGet,httputil.MethodPost, etc. - Severity Levels:
severity.SeverityError,severity.SeverityWarning, etc.
HTTP status codes have no string constants. The standard library's are int
(http.StatusOK), which is what an int-taking API wants, including builder.WithResponse.
An OAS document keys responses by string, so write the literal there ("200"), which is how
httputil.StandardHTTPStatusCodes stores its own keys. Use httputil.IsStatusCode,
httputil.IsSuccessStatusCode, or httputil.IsStandardStatusCode to check a code a document
supplies.
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 is any, because a schema may declare
one type or several. Read it through internal/schemautil, which owns the assertion
and documents the shapes it can hold.
Pointer semantics:
// Use pointer slices for nested structures
servers := []*parser.Server{
&parser.Server{URL: "https://api.example.com"}, // ✅ Correct
}Security Fixes
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 ./...Boundaries - DO NOT Modify
.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)
Acceptance Criteria
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 & PR Format
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
Common Pitfalls
- Type assertions: Don't assume
schema.Typeis always a string - read it throughinternal/schemautil - 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
Architecture
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 fixturesEach public package includes doc.go (package docs) and example_test.go (godoc examples).
Development Agents
Four specialized agents streamline the development workflow. They are automatically invoked based on context and can chain together.
Agent Overview
| 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 |
Workflow Chain
User Request
│
▼
┌─────────────┐
│ Architect │ ← Plans the implementation
└──────┬──────┘
│
▼
┌─────────────┐
│ Developer │ ← Implements in phases with checkpoints
│ (pause) │ ──── User: "continue" ────┐
└──────┬──────┘ │
│ ◄────────────────────────────────┘
▼
┌─────────────┐
│ Maintainer │ ← Reviews changes
└──────┬──────┘
│
▼
┌─────────────┐
│ DevOps │ ← Prepares release (when needed)
└─────────────┘Checkpoint Mode (Developer)
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
Review Severity Levels (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) |
Agent Files
Located in .claude/agents/:
architect.md- Planning and designmaintainer.md- Code review and standardsdeveloper.md- Implementation executiondevops-engineer.md- DevOps and tooling
Resources
- 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
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

