Claude-skill-registry 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", "architecture specification", or is working with YAML entity files in .graph/entities/. Provides guidance for maintaining architecture-as-code consistency.
git clone https://github.com/majiayu000/claude-skill-registry
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/architecture-graph" ~/.claude/skills/majiayu000-claude-skill-registry-architecture-graph && rm -rf "$T"
skills/data/architecture-graph/SKILL.mdArchitecture 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:
: PascalCase entity identifiername
: Human-readable purposedescription
: Typed fields with constraints (primary, unique, nullable)fields
: Connections to other entitiesrelations
: Links to implementation code via anchorscode_refs
Relations
Relations define how entities connect:
| Type | Description | Example |
|---|---|---|
| One-to-many | User has_many Todos |
| Many-to-one (inverse) | Todo belongs_to User |
| One-to-one | User has_one Profile |
| Many-to-many via junction | User 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
| Command | Purpose |
|---|---|
| Verify spec-code synchronization |
| Query entity details |
| Analyze change impact |
MCP Tools
The Cartographer MCP server provides these tools:
| Tool | Purpose |
|---|---|
| Analyze codebase, find anchors |
| Get entity details |
| Check spec compliance |
| Analyze change dependencies |
| Fetch 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:
- Data structure/interfacemodel
- Validation rulesschema
- API endpoint handlerhandler
- Database access layerrepository
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
- Create
with all fields.graph/entities/new-entity.yaml - Add relations to connected entities
- Create code files with anchor comments
- Run
to verify/graph:check
Adding a Relation
- Update both entity YAML files
- Add foreign key field if needed
- Update both code_refs sections
- Verify with
/graph:check
Modifying a Field
- Run
first/graph:impact Entity.field - Update the entity YAML
- Modify all code_refs locations
- 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:
| Type | Description |
|---|---|
| Universally unique identifier |
| Text data |
| Whole numbers |
| Decimal numbers |
| True/false |
| Date and time |
| Date only |
| JSON object |
| Fixed set of values |
| List of items |
Troubleshooting
Anchor Not Found
If
/graph:check reports missing anchors:
- Verify the anchor comment syntax is correct
- Check that start and end tags match
- Ensure the file path in code_refs is correct
Orphaned Anchor
If code has an anchor but spec doesn't reference it:
- Add the code_ref to the entity YAML, or
- Remove the anchor comment from code
Type Mismatch
If field types don't match:
- Check the entity YAML for the expected type
- Update the implementation to match
- Consider if spec needs updating instead