Skip to content

AI Agent Integration

SGD provides governance context to AI coding agents through two channels: a static CLAUDE.md file generated per repository, and a real-time MCP server that agents can query during development.

The result: AI agents consult your governance model instead of guessing.


Two channels, one goal

ChannelTypeWhen it is usedWhat it provides
CLAUDE.mdStatic file, committed to repoEvery time an agent opens the repositoryBaseline context: change protocol, capability map, design constraints, key dependencies
MCP ServerReal-time APIDuring active development, when the agent needs specificsLive data: current specs, impact analysis, coherence scores, design system rules

Both channels complement each other. CLAUDE.md gives the agent the "always true" context without needing a network call. The MCP server gives it the "right now" context that changes as specs are updated and scores evolve.


Channel 1: CLAUDE.md (Static Context)

SGD auto-generates and maintains a CLAUDE.md file in the root of every governed repository. This file is committed to the repository, so it is available to any AI agent that reads the codebase — no configuration required.

What CLAUDE.md contains

The generated file includes four sections:

1. Change Protocol

markdown
## Change Protocol
- All feature work must reference a specification (e.g., `Refs: PAY-REFUND-001`)
- PRs are checked against the SGD governance model
- Design system rules are enforced for .tsx/.jsx changes

2. Capability Map

markdown
## This Repository in Context
- Capability: Payment Processing
- Sibling repos: payment-gateway, billing-service, payment-types
- Upstream: auth-api (authentication)
- Downstream: reporting-service (consumes payment events)

3. Design Constraints

markdown
## Design Constraints
- UI components: import from @acme/ui (canonical library)
- No inline styles in .tsx files
- Colours must use design tokens (var(--color-*))
- API responses must follow the shared response envelope

4. Key Dependencies

markdown
## Key Dependencies
- @acme/ui v3.2.0 — shared component library
- @acme/api-types v1.8.0 — shared API type definitions
- DataTable component — used by 4 features across 4 repos

How it stays current

SGD regenerates CLAUDE.md when:

  • The capability model changes (repo reassigned, new sibling added)
  • Design system rules are updated
  • A new feature spec is created that affects this repository
  • The dependency graph changes significantly

The regeneration creates a commit on the default branch. If you prefer, you can configure SGD to open a PR instead.

Works without MCP

Even if your AI tooling does not support MCP, CLAUDE.md provides governance context. Claude Code, Cursor, and GitHub Copilot all read CLAUDE.md files automatically. This is the zero-configuration path to governed AI development.


Channel 2: MCP Server (Real-Time Context)

For AI agents that support the Model Context Protocol, SGD exposes an MCP server with five tools. These give the agent real-time access to governance data during active development.

MCP tools

ToolDescriptionExample use case
get_capability_modelReturns the full capability model for the organisation, or a subtree for a specific capabilityAgent needs to understand where this repo fits in the wider system
get_feature_specReturns a specific feature specification by ID, including acceptance criteria and affected reposAgent is implementing PAY-REFUND-001 and needs the full spec
get_design_systemReturns the active design system rules for this repository, including canonical components and banned patternsAgent is writing a React component and needs to know which imports to use
get_impact_analysisReturns the impact graph for a given component, endpoint, or spec — what depends on it and what would be affected by a changeAgent is modifying a shared component and wants to understand the blast radius
get_coherence_scoreReturns the current coherence score and dimension breakdown for a repository or capabilityAgent wants to understand the current governance posture before making changes

Example: agent writing a new feature

Here is how an AI agent uses both channels when implementing a feature:

  1. Agent opens the repo — Reads CLAUDE.md, learns this is the refund-processor repo in the Payment Processing capability, governed by SGD

  2. Agent reads the spec — Calls get_feature_spec("PAY-REFUND-001") to get the full specification, acceptance criteria, and list of affected files

  3. Agent checks design rules — Calls get_design_system() to learn that Button must come from @acme/ui and inline styles are banned

  4. Agent checks impact — Before modifying the shared RefundStatus component, calls get_impact_analysis("RefundStatus") to see that 2 other repos depend on it

  5. Agent writes the code — With full context, the agent produces code that follows the spec, uses canonical components, and includes Refs: PAY-REFUND-001 in the commit message

  6. PR passes governance checks — Because the agent had the right context, the PR passes spec traceability and design system checks on the first try

Configuring the MCP server

Add the SGD MCP server to your AI agent's configuration:

json
{
  "mcpServers": {
    "sgd": {
      "url": "https://api.sgd-platform.com/mcp",
      "headers": {
        "Authorization": "Bearer ${SGD_TOKEN}"
      }
    }
  }
}

The token is generated in the SGD dashboard under Settings > API Access. It is scoped to your organisation and respects the same permission model as the dashboard.


The result

Without SGD integration, AI agents make reasonable guesses based on the code they can see. They import the wrong component library, miss design constraints, create PRs without spec references, and modify shared components without understanding the blast radius.

With SGD integration, AI agents operate with the same context as a senior developer who has been on the team for years:

Without SGDWith SGD
Agent imports a local Button componentAgent imports Button from @acme/ui
Agent creates a PR with no spec referenceAgent includes Refs: PAY-REFUND-001
Agent modifies shared component without checking impactAgent calls get_impact_analysis first
Agent uses hardcoded coloursAgent uses design tokens
PR fails governance checks, requires reworkPR passes on the first attempt

The governance model is only as effective as its reach. By meeting AI agents where they work — in the repo and through MCP — SGD ensures that governed development is the default, not the exception.


Next steps

Powered by RepoSentry