Skip to content
Architecture Graph logo

Architecture Graph

This skill should be used when the user asks about "entities", "relations", "architecture graph", "spec-driven development", "code annotations", "@graph anchors", mentions ".graph/" directory, asks to "add entity", "create relation", "verify sync", "check drift", discusses "code_refs", "architect...

SKILL.md

Full skill instructions

Architecture Graph Skill

Overview

Cartographer enables spec-driven development where architecture specifications in .graph/ define the source of truth for entities, relations, and code structure. The code follows the spec, not the other way around.

Core Concepts

Entities

Entities are defined in .graph/​entities/​*.yaml:

name: User
description: Application user account
fields:
  - name: id
    type: uuid
    primary: true
  - name: email
    type: string
    unique: true
  - name: name
    type: string
relations:
  - name: todos
    entity: Todo
    type: has_many
code_refs:
  model:
    anchor: "@graph:User.model"
  schema:
    anchor: "@graph:User.schema"

Key properties:

  • name: PascalCase entity identifier
  • description: Human-readable purpose
  • fields: Typed fields with constraints (primary, unique, nullable)
  • relations: Connections to other entities
  • code_refs: Links to implementation code via anchors

Relations

Relations define how entities connect:

TypeDescriptionExample
has_manyOne-to-manyUser has_many Todos
belongs_toMany-to-one (inverse)Todo belongs_to User
has_oneOne-to-oneUser has_one Profile
has_many_throughMany-to-many via junctionUser has_many Categories through TodoCategories

Code References (code_refs)

Code is linked to specs via anchor comments in source files:

// @graph:User.model
export interface User {
  id: string;
  email: string;
  name: string;
}
// @end:User.model

Anchor syntax:

  • Start: // @graph:EntityName.refType
  • End: // @end:EntityName.refType
  • Works in any language with comments

Spec-Driven Workflow

When implementing or modifying code, always follow this workflow:

1. Check the Spec First

Before writing any code, read the entity YAML in .graph/​entities/:

# Use /​graph:entity command
/​graph:entity User

Or read the file directly to understand:

  • What fields are expected
  • What relations exist
  • Where code should be anchored

2. Follow the Spec

Implement exactly what's specified:

  • Use the same field names and types
  • Implement all defined relations
  • Place code in the anchored locations

3. Add Anchors

Wrap implementations with @graph: comments:

// @graph:User.model
// Implementation here
// @end:User.model

4. Verify Sync

Run /​graph:check to validate that code matches spec.

Available Commands

CommandPurpose
/​graph:checkVerify spec-code synchronization
/​graph:entity <name>Query entity details
/​graph:impact <entity>Analyze change impact

MCP Tools

The Cartographer MCP server provides these tools:

ToolPurpose
scanAnalyze codebase, find anchors
queryGet entity details
validateCheck spec compliance
impactAnalyze change dependencies
get_relationsFetch entity relations

Best Practices

1. Spec-First Development

Always define in .graph/ before implementing:

1. Create/​update .graph/​entities/​new-entity.yaml
2. Implement code with anchors
3. Run /​graph:check

2. Atomic Anchors

One anchor per logical unit:

  • model - Data structure/​interface
  • schema - Validation rules
  • handler - API endpoint handler
  • repository - Database access layer

3. Keep in Sync

Run /​graph:check after every modification to catch drift early.

4. Document Relations

Make entity connections explicit in both entities:

# user.yaml
relations:
  - name: todos
    entity: Todo
    type: has_many

# todo.yaml
relations:
  - name: user
    entity: User
    type: belongs_to

Common Tasks

Adding a New Entity

  1. Create .graph/​entities/​new-entity.yaml with all fields
  2. Add relations to connected entities
  3. Create code files with anchor comments
  4. Run /​graph:check to verify

Adding a Relation

  1. Update both entity YAML files
  2. Add foreign key field if needed
  3. Update both code_refs sections
  4. Verify with /​graph:check

Modifying a Field

  1. Run /​graph:impact Entity.field first
  2. Update the entity YAML
  3. Modify all code_refs locations
  4. Run /​graph:check

Checking Impact Before Changes

Before modifying an entity:

/​graph:impact User.email

This shows:

  • All code locations that need updates
  • Related entities affected
  • Suggested action items

Field Types Reference

Common field types in entity definitions:

TypeDescription
uuidUniversally unique identifier
stringText data
integerWhole numbers
floatDecimal numbers
booleanTrue/​false
timestampDate and time
dateDate only
jsonJSON object
enumFixed set of values
arrayList of items

Troubleshooting

Anchor Not Found

If /​graph:check reports missing anchors:

  1. Verify the anchor comment syntax is correct
  2. Check that start and end tags match
  3. Ensure the file path in code_refs is correct

Orphaned Anchor

If code has an anchor but spec doesn't reference it:

  1. Add the code_ref to the entity YAML, or
  2. Remove the anchor comment from code

Type Mismatch

If field types don't match:

  1. Check the entity YAML for the expected type
  2. Update the implementation to match
  3. Consider if spec needs updating instead

More skills from majiayu000

xiaohongshu logo
majiayu000/claude-arsenal

xiaohongshu

xiaohongshu

286 148
View
agent-task-conductor logo
majiayu000/claude-skill-registry

agent-task-conductor

Conduct multi-agent task orchestration and workflow coordination.

663 1
View
conductor-setup logo
majiayu000/claude-skill-registry

conductor-setup

Initialize project with Conductor artifacts (product definition,

663 1
View
animation-designer logo
majiayu000/claude-skill-registry

animation-designer

Expert in web animations, transitions, and motion design using Framer Motion and CSS

663 1
View
diagramming logo
majiayu000/claude-skill-registry

diagramming

Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...

663 1
View
h3-pg logo
majiayu000/claude-skill-registry-data

h3-pg

PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.

23 1
View
conductor-development logo
majiayu000/claude-skill-registry

conductor-development

Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...

663 1
View
conductor-status logo
majiayu000/claude-skill-registry

conductor-status

Display project status, active tracks, and next actions

663 1
View
dockerization logo
majiayu000/claude-skill-registry

dockerization

Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.

663 1
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View