ambient-api-server
Skill131 starsChanged 6 months agoMITView on GitHub
Activates when: Working in components/ambient-api-server/ or asked about API server, REST endpoints, gRPC, OpenAPI, or plugins. You are working on the Ambient API Server — a Go REST + gRPC server built on the rh-trex-ai framework. It serves the Ambient Platform's resource API under /api/ambient/v1/. Every resource kind is a self-contained plugin in plugins/<kind>/. The 8-file structure is mandatory: Generate scaffold: go run ./scripts/generator.go --kind Foo --fields "name:string,status:string" Never edit pkg/api/openapi/ files — they are generated from openapi/openapi.yaml.
In this repository19 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- alignSkill
- amber-reviewSkill
- workflowSkill
- ambient-pr-testSkill
- ambientSkill
- dev-clusterSkill
- deploySkill
- devflowSkill
- discoverSkill
- cypress-demoSkill
- frontend-developmentSkill
- grpc-devSkill
- unleash-flagSkill
- memorySkill
- pr-fixerSkill
- scaffoldSkill
- specSkill
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 0 are distinctive, and 8 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
8
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Very specific: line 13
Every resource kind is a self-contained plugin in plugins/<kind>/.
- Very specific: line 38
Never edit pkg/api/openapi/ files — they are generated from openapi/openapi.yaml.
- Very specific: line 69
Run make generate (updates Go stubs)
- Very specific: line 72
Write table-driven tests in *_test.go
- Very specific: line 73
Run make test — all green
- Very specific: line 74
Run make generate in ambient-sdk to propagate to SDKs
- Very specific: line 75
Run make build in ambient-cli to update CLI
- Very specific: line 79
Add streaming RPC to proto/ambient/v1/<resource>.proto
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill 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
Skill: ambient-api-server
Activates when: Working in components/ambient-api-server/ or asked about API server, REST endpoints, gRPC, OpenAPI, or plugins.
What This Skill Knows
You are working on the Ambient API Server — a Go REST + gRPC server built on the rh-trex-ai framework. It serves the Ambient Platform's resource API under /api/ambient/v1/.
Plugin System (critical)
Every resource kind is a self-contained plugin in plugins/<kind>/. The 8-file structure is mandatory:
plugins/<kind>/
plugin.go # route + gRPC registration
model.go # GORM DB struct
handler.go # HTTP handlers
service.go # business logic
dao.go # DB layer
presenter.go # model → API response
migration.go # DB schema
mock_dao.go # test mock
*_test.go # table-driven testsGenerate scaffold: go run ./scripts/generator.go --kind Foo --fields "name:string,status:string"
OpenAPI is the source of truth
openapi/openapi.yaml
→ make generate → pkg/api/openapi/ (DO NOT EDIT)
→ ambient-sdk make generate → all SDKsNever edit pkg/api/openapi/ files — they are generated from openapi/openapi.yaml.
gRPC
- Protos:
proto/ambient/v1/ - Stubs:
pkg/api/grpc/ambient/v1/(generated) - Auth:
pkg/middleware/bearer_token_grpc.go - Watch streams: server-side streaming RPCs — emit AG-UI events to clients
- Ownership bypass: when JWT username not in context (test tokens), skip per-user ownership check
Environments
AMBIENT_ENV | Auth | DB | Use for |
development | disabled | localhost:5432 | local make run |
integration_testing | mock | testcontainer (ephemeral) | make test |
production | JWT required | cluster Postgres | deployed |
Test setup
systemctl --user start podman.socket
export DOCKER_HOST=unix:///run/user/$(id -u)/podman/podman.sock
cd components/ambient-api-server && make testRunbook: Add a New API Resource
- Define schema in
openapi/openapi.yaml - Run
make generate(updates Go stubs) go run ./scripts/generator.go --kind MyResource --fields "..."- Implement
service.goanddao.gobusiness logic - Write table-driven tests in
*_test.go - Run
make test— all green - Run
make generateinambient-sdkto propagate to SDKs - Run
make buildinambient-clito update CLI
Runbook: Add a gRPC Watch Stream
- Add streaming RPC to
proto/ambient/v1/<resource>.proto make generate→ updates stubs inpkg/api/grpc/- Implement handler in
plugins/<kind>/plugin.go— register gRPC server - Implement fan-out: in-memory subscriber map keyed by session ID
- Feed events from runner gRPC push → fan-out → all subscribers
- Skip ownership check for non-JWT tokens
- Test with:
acpctl session messages -f --project <p> <session>
Common Pitfalls
- Never edit
pkg/api/openapi/— runmake generateinstead panic()is forbidden — useerrors.NewInternalServerError(...)- DB migrations are additive — never drop columns in production overlays
- Test token ownership —
WatchSessionMessagesmust skip username check when JWT username is absent from context
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.

