architecture

A set of architecture rules for a Go project where packages communicate through shared interfaces in a central API package. The central package acts as a service locator and must not depend on other project packages.

In plain words
What is it for?
Adding a new handler by defining its interface in internal/api/handlers.go and connecting packages through the central API layer.
Why use it?
It keeps packages separated so they can be changed and tested independently, while avoiding direct dependencies and circular imports.

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/giantswarm/muster/architecture
Clone the repo
git clone --depth 1 https://github.com/giantswarm/muster

Made for: Cursor.

Per session 1,283 This file is loaded in full into every session.
When invoked 1,283 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.01283 $0.01283
Opus 5 $0.00642 $0.00642
Sonnet 5 $0.00257 $0.00257
Haiku 4.5 $0.00128 $0.00128

Measured yesterday against content hash f7eadfd8c142, 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 yesterday.

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 · 105 lines

How it starts

The opening of the file, as written. The whole thing — 105 lines — stays where its author put it; the contents beside it link to each section on GitHub.

  • Architectural principles

    • This document outlines the fundamental architectural principles and patterns for the muster codebase. Adherence to these guidelines is mandatory to maintain a clean, decoupled, and testable system.
  • The API Service Locator Pattern

    • All inter-package communication MUST go through the central API layer. This is the most critical rule in our architecture. It prevents direct coupling between packages, enabling them to be developed, tested, and refactored independently.
  • Core Concepts

    • Central API: The internal/api package acts as a service locator. It contains handlers for all core muster functionality and also the tool definitions exposed by the aggregator package.
    • Interface-Driven: Packages communicate using interfaces defined in internal/api/handlers.go. They do not know about each other's concrete implementations.
    • One-Way Dependency: All packages can depend on internal/api, but internal/api depends on no other package in the project. This is crucial for preventing circular dependencies.
  • Define Interface in API: Add a new handler interface to internal/api/handlers.go.

    // internal/api/handlers.go
    type MyServiceHandler interface {
        DoSomething(ctx context.Context) error
    }
    
  • Implement Adapter in Service Package: In the package providing the functionality (e.g., internal/myservice), create an api_adapter.go. This adapter implements the interface and calls the package's internal logic.

    // internal/myservice/api_adapter.go
    type Adapter struct {
        logic *ServiceLogic
    }
    func (a *Adapter) DoSomething(ctx context.Context) error {
        return a.logic.performAction(ctx)
    }
    
  • Register the Adapter: Implement a Register() method on the adapter that calls the registration function in the api package.

    // internal/myservice/api_adapter.go
    func (a *Adapter) Register() {
        api.RegisterMyService(a)
    }
    
  • Consume via API: Any other package that needs to use the service MUST retrieve the handler from the api package. It MUST NOT import the service package directly.

    // in another_package/logic.go
    import "github.com/giantswarm/muster/internal/api"
    
    func DoWork(ctx context.Context) {
        handler := api.GetMyService()
        if handler == nil {
            // Handle case where service is not available
            return
        }
        handler.DoSomething(ctx)
    }
    
  • Workflow executions

    • From the user perspective workflows are executed via the tools workflow_<workflow-name>.
    • In the workflows and api package these workflow execution tools are still called action_<workflow-name>.
    • The aggregator maps the action_<workflow-name> tools to the actual workflow_<workflow-name>.
  • CRITICAL: Anti-Patterns

    • NEVER import workflow, mcpserver, serviceclass and service packages directly. This creates tight coupling and violates the core architectural principle.
    • NEVER USE TIMER/SLEEP/WAIT TO FIX TESTS OR RACE CONDITIONS. NEVER!!
    • ALWAYS retrieve handlers from the api package.
    • Don't change schema.json manually It is generated via muster test --generate-schema and changes are the result of the actual api of muster serve.
  • BDD test scenarios

    • Execute test scenarios like this: muster test --scenario <scenario> --verbose
    • Make sure muster is up to date: Use go install
    • Always update muster after a code change in go
    • There is no need to start muster serve: Each test scenario is executed in its own environment and its own instance of muster serve
    • Always treat the scenario as the defined and supposed user behavior: If a scenario fails it is most likely a regression and the code needs to be fixed and not the scenario.
    • To see debug messages during test scenario execution: You need to add a --debug flag: muster test --scenario <scenario> --verbose --debug
    • Never ever stop or commit with failing test scenarios: You must fix them.

Read the full file on GitHub · 105 lines

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. yesterday First seen · 105 lines · 1,283 tokens per session scan A f7eadfd8c142

Subscribe to this mod's changes

architecture is a cursor rule published in the GitHub repository giantswarm/muster (28 stars, last pushed 2d ago), licensed Apache-2.0. It adds 1,283 tokens to every session, about $0.0064 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.