SDK Guide
Driving an LLM with Structure
Use the intelligence, playbooks, approaches, and regions barrels to give an agent a structured map of your graph instead of free-text prompts.
Why structure beats prose
Free-text prompts force the model to infer schema from token order. UPG carries the schema explicitly: 312 entity types, typed edges with forward/reverse verbs, anti-patterns, and region-anchored playbooks. Pass those structures into the context window and the agent stops guessing the shape of your graph.
Four barrels matter most for agents: intelligence (anti-pattern catalogue — the rules the graph is judged against), playbooks (23 region-anchored bootstrap sequences — 'do these steps in order to scaffold this region'), approaches (5 cartographic orientations — Plan / Inspect / Prioritise / Trace / Reflect), regions (10 super-domains organising the 36 atomic domains).
import { UPG_ANTI_PATTERNS } from '@unified-product-graph/core/intelligence'
import { UPG_APPROACHES_BY_ID } from '@unified-product-graph/core/approaches'
import { UPG_REGIONS } from '@unified-product-graph/core/regions'
// Pass the structured context the model needs
const systemContext = {
anti_patterns: UPG_ANTI_PATTERNS.map(p => ({ id: p.id, severity: p.severity })),
approaches: Object.values(UPG_APPROACHES_BY_ID).map(a => ({ id: a.id, label: a.label })),
regions: UPG_REGIONS.map(r => ({ id: r.id, label: r.label })),
}The context pattern
Spock’s canonical pattern: when an agent is about to mutate the graph, pre-fetch the relevant playbook for the region it’s working in, surface the anti-patterns that could fire, and pass the active approach as a hint for tone. The agent stops inventing structure and starts following it.
// Before writing a node, ask: which playbook, which approach, which anti-patterns?
import { BUSINESS_GTM_GROWTH_PLAYBOOK } from '@unified-product-graph/core/playbooks'
const guidance = {
active_playbook: BUSINESS_GTM_GROWTH_PLAYBOOK.region,
next_step: BUSINESS_GTM_GROWTH_PLAYBOOK.steps[0],
}