agentleFS
ambient-codeambient-code/platform/skills/sessions/ambient-api-server/SKILL.md

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.

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
  1. Very specific:

    Every resource kind is a self-contained plugin in plugins/<kind>/.

    line 13
  2. Very specific:

    Never edit pkg/api/openapi/ files — they are generated from openapi/openapi.yaml.

    line 38
  3. Very specific:

    Run make generate (updates Go stubs)

    line 69
  4. Very specific:

    Write table-driven tests in *_test.go

    line 72
  5. Very specific:

    Run make test — all green

    line 73
  6. Very specific:

    Run make generate in ambient-sdk to propagate to SDKs

    line 74
  7. Very specific:

    Run make build in ambient-cli to update CLI

    line 75
  8. Very specific:

    Add streaming RPC to proto/ambient/v1/<resource>.proto

    line 79

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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 tests

Generate 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 SDKs

Never 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_ENVAuthDBUse for
developmentdisabledlocalhost:5432local make run
integration_testingmocktestcontainer (ephemeral)make test
productionJWT requiredcluster Postgresdeployed

Test setup

systemctl --user start podman.socket
export DOCKER_HOST=unix:///run/user/$(id -u)/podman/podman.sock
cd components/ambient-api-server && make test

Runbook: Add a New API Resource

  1. Define schema in openapi/openapi.yaml
  2. Run make generate (updates Go stubs)
  3. go run ./scripts/generator.go --kind MyResource --fields "..."
  4. Implement service.go and dao.go business logic
  5. Write table-driven tests in *_test.go
  6. Run make test — all green
  7. Run make generate in ambient-sdk to propagate to SDKs
  8. Run make build in ambient-cli to update CLI

Runbook: Add a gRPC Watch Stream

  1. Add streaming RPC to proto/ambient/v1/<resource>.proto
  2. make generate → updates stubs in pkg/api/grpc/
  3. Implement handler in plugins/<kind>/plugin.go — register gRPC server
  4. Implement fan-out: in-memory subscriber map keyed by session ID
  5. Feed events from runner gRPC push → fan-out → all subscribers
  6. Skip ownership check for non-JWT tokens
  7. Test with: acpctl session messages -f --project <p> <session>

Common Pitfalls

  • Never edit pkg/api/openapi/ — run make generate instead
  • panic() is forbidden — use errors.NewInternalServerError(...)
  • DB migrations are additive — never drop columns in production overlays
  • Test token ownership — WatchSessionMessages must skip username check when JWT username is absent from context

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.