|
| 1 | +<!-- OPENSPEC:START --> |
| 2 | +# OpenSpec Instructions |
| 3 | + |
| 4 | +These instructions are for AI assistants working in this project. |
| 5 | + |
| 6 | +Always open `@/openspec/AGENTS.md` when the request: |
| 7 | +- Mentions planning or proposals (words like proposal, spec, change, plan) |
| 8 | +- Introduces new capabilities, breaking changes, architecture shifts, or big performance/security work |
| 9 | +- Sounds ambiguous and you need the authoritative spec before coding |
| 10 | + |
| 11 | +Use `@/openspec/AGENTS.md` to learn: |
| 12 | +- How to create and apply change proposals |
| 13 | +- Spec format and conventions |
| 14 | +- Project structure and guidelines |
| 15 | + |
| 16 | +Keep this managed block so 'openspec update' can refresh the instructions. |
| 17 | + |
| 18 | +<!-- OPENSPEC:END --> |
| 19 | + |
| 20 | +# Commands |
| 21 | +- **Test all**: `go test ./... -race` |
| 22 | +- **Test package**: `go test ./mcp -v` or `go test ./server -v` |
| 23 | +- **Test single**: `go test -run TestName ./package -v` |
| 24 | +- **Coverage**: `go test -coverprofile=coverage.txt -covermode=atomic $(go list ./... | grep -v '/examples/' | grep -v '/testdata' | grep -v '/mcptest' | grep -v '/server/internal/gen')` |
| 25 | +- **Lint**: `golangci-lint run` (uses .golangci.yml config) |
| 26 | +- **Generate**: `go generate ./...` (regenerates hooks and request handlers) |
| 27 | + |
| 28 | +# Code Style |
| 29 | +- **Imports**: Standard library first, then third-party, then local packages (goimports handles this) |
| 30 | +- **Naming**: Use Go conventions - exported names (PascalCase), unexported names (camelCase), acronyms uppercase (HTTP, JSON, MCP) |
| 31 | +- **Error handling**: Return sentinel errors (e.g., `ErrMethodNotFound`), wrap with `fmt.Errorf("context: %w", err)`, use `errors.Is/As` for checking |
| 32 | +- **Types**: Use explicit types; avoid `any` except for protocol flexibility (e.g., `Arguments any`); prefer strongly-typed structs |
| 33 | +- **Comments**: All exported types/functions MUST have godoc comments starting with the name; no inline comments unless necessary |
| 34 | +- **Testing**: Use `testify/assert` and `testify/require`; table-driven tests with `tests := []struct{ name, ... }`; test files end in `_test.go` |
| 35 | +- **Context**: Always accept `context.Context` as first parameter in handlers and long-running functions |
| 36 | +- **Thread safety**: Use `sync.Mutex` for shared state; document thread-safety requirements in comments |
| 37 | +- **JSON**: Use json tags with `omitempty` for optional fields; use `json.RawMessage` for flexible/deferred parsing |
0 commit comments