architecture

A set of rules for structuring and implementing a Go software project called AI Lamp OpenClaw. Go is a programming language, and the rules cover file locations, dependency setup, API responses, validation, errors, and concurrent work.

In plain words
What is it for?
Use it while adding handlers, services, domain types, providers, or shared libraries. It also guides Google Wire dependency generation, response formatting, error wrapping, request validation, logging, and cancellation of goroutines.
Why use it?
It gives contributors consistent decisions for where code belongs and how services communicate. This reduces integration mistakes and makes failures, request validation, and background tasks easier to handle consistently.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/autonomous-ai/autonomous-os/architecture
Clone the repo
git clone --depth 1 https://github.com/autonomous-ai/autonomous-os

Made for: Cursor.

Per session 407 This file is loaded in full into every session.
When invoked 407 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00407 $0.00407
Opus 5 $0.00204 $0.00204
Sonnet 5 $0.00081 $0.00081
Haiku 4.5 $0.00041 $0.00041

Measured 3d ago against content hash eee522c2d571, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

architecture scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/architecture.mdc · 52 lines

What it actually says

Architecture Rules

Package Structure

  • Handlers go in server/<domain>/delivery/http/handler.go
  • Services go in internal/<domain>/service.go
  • Domain types go in domain/<type>.go
  • Wire providers go in server/wire.go and bootstrap/wire.go
  • Shared libraries go in lib/

Dependency Injection

  • Use Google Wire for compile-time DI — no runtime reflection
  • After changing any provider signature: run make generate
  • Never manually edit wire_gen.go files

API Conventions

  • All responses use serializers.ResponseSuccess(data) or serializers.ResponseError(err)
  • Response format: {"status": 1|0, "data": <payload>|null, "message": null|"error"}
  • Validate requests with go-playground/validator at handler level
  • Return early on validation failure with http.StatusBadRequest

Error Handling

  • Always wrap errors with context: fmt.Errorf("operation: %w", err)
  • Log with component prefix: log.Println("[led] starting engine")
  • Never swallow errors silently

Goroutines & Concurrency

  • Always pass context.Context for cancellation
  • Background goroutines must select on ctx.Done()
  • Use sync.Mutex for shared state, not channels (unless fan-out pattern)

Configuration

  • Config in config/config.json managed by server/config/config.go
  • Use notification channel for propagating config changes to services
  • Never hardcode secrets — load from config file

Build

  • Cross-compile target: GOOS=linux GOARCH=arm64
  • Version injected via ldflags — never commit binaries
  • Lint with golangci-lint run before committing
Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 52 lines · 407 tokens per session scan A eee522c2d571

Subscribe to this mod's changes

architecture is a cursor rule published in the GitHub repository autonomous-ai/autonomous-os (256 stars, last pushed 3d ago), licensed Apache-2.0. It adds 407 tokens to every session, about $0.0020 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.