/bridge-ds:learning-from-correctionsfrom bridge-ds
Diffs current Figma state against a snapshot, classifies changes as design system learnings or hardcoded flags, and persists corrections to the active recipe.
Ships in bridge-ds. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
{{ACTIVE_RULES}}
Closes the feedback loop from manual Figma edits back into Bridge's knowledge base. Diffs the live Figma state against the saved snapshot, classifies each correction as a LEARNING (DS-compliant → persisted) or a FLAG (hardcoded → surfaced), updates learnings.json, and auto-patches the active recipe when eligible.
Invoke when the user:
specs/active/ with a snapshotDo NOT use if:
make first (use generating-figma-design)generating-figma-design with a new descriptionshipping-and-archivingBefore starting, load:
references/transport-adapter.md (repo-root) — for Figma state re-readreferences/compiler-reference.md (repo-root) — for scene graph recompile (if re-executing after fix)specs/active/ (abort if missing: "No active CSpec. Run: make <description>")specs/active/{name}-snapshot.json (abort if missing: "No snapshot found. The design must have been generated with make. Run make first.")references/transport-adapter.md (repo-root) Section F)specs/active/{name}.cspec.yamlspecs/active/{name}-snapshot.jsonknowledge-base/learnings.json (create empty structure if file doesn't exist)knowledge-base/registries/variables.json for token resolutionRun a node tree extraction script via Plugin API execution, using the rootNodeId and fileKey from the snapshot's meta.
Console transport:
figma_execute({
code: "return (async function() { ... extraction script with rootNodeId ... })();"
})
Official transport:
use_figma({
fileKey: "{fileKey}",
description: "Re-extract node tree for fix diff",
code: "... extraction script without IIFE wrapper ..."
})
The extraction script walks the node tree and captures: id, name, type, layoutMode, itemSpacing, padding*, cornerRadius, fills, boundVariables, width, height, componentKey, children.
Compare the two JSON trees in context. Claude performs this comparison directly.
Match strategy:
id (stable across edits)layoutMode, itemSpacing, paddingTop/Bottom/Left/RightcornerRadius, fills, boundVariableswidth, heightcomponentKey (detect swapped components)Ignore:
For each detected change:
Does the new value use a DS token (bound variable)?
-> YES: Classify as LEARNING (DS-compliant correction)
-> NO (hardcoded hex, raw px, unbound): Classify as FLAG (needs attention)
Token resolution: Check boundVariables in the current tree. If the property has a bound variable ID, resolve it against registries/variables.json to get the token name.
For each LEARNING-classified change:
Determine context:
screenType: from the CSpec's meta.pattern or intentcomponent: nearest component ancestor name, or the node's own name if it's a component instancesection: parent frame name (e.g., "header", "content", "sidebar")Check for existing learning: Search learnings.json for a learning with matching context + change.property + change.to.token
signals, append to historyGenerate rule: Write a human-readable rule describing the preference (e.g., "For settings screens, cards use spacing/medium (not large)")
Check promotion: After updating signals, check if any contextual learning qualifies for global promotion:
signals >= 3screenType valuesFor each FLAG-classified change:
flags array in learnings.jsonIf a recipe was used (check snapshot.meta.recipe):
graph to reflect the learned changesversion, update lastEvolvedAtevolution_logIf a learning is promoted to global scope, scan ALL recipes and patch any where the change applies.
If learnings were extracted (DS-compliant changes):
Write updated learnings.json to knowledge-base/learnings.json.
Update meta.lastUpdated to today's date.
Re-save the snapshot with the current Figma state (so future fix runs diff against the latest corrections, not the original generation).
## Fix: {name}
### Changes detected: {total count}
### Learnings extracted: {count}
| # | Context | Property | From | To | Rule |
|---|---------|----------|------|----|------|
| 1 | settings / card | itemSpacing | spacing/large (24) | spacing/medium (16) | Cards in settings use medium spacing |
### Flags: {count}
| # | Node | Issue | Suggestion |
|---|------|-------|------------|
| 1 | StatusBadge | Hardcoded hex #FF5722 | Use $color/text/error/default |
### Recipe patches: {count}
- Recipe "{name}" v{version}: {description of patch}
### Promotions: {count}
- "{rule}" promoted to global (signals: {n}, screenTypes: {list})
### CSpec updated: {yes/no}
{list of CSpec changes if any}
Fix complete for {name}.
Learnings: {n} extracted ({n} new, {n} reinforced, {n} promoted)
Flags: {n} hardcoded values flagged
Recipe: {patched | not applicable}
Options:
- Continue editing in Figma, then run `fix` again
- "done" to archive and ship
fix again after more changesdone" (handled by shipping-and-archiving)Every LEARNING MUST reference a token from the current
registries/variables.json / registries/text-styles.json. A
LEARNING that points to a non-existent token is a gate failure.
Every FLAG MUST be surfaced to the user before saving the snapshot.
See the full catalog at references/red-flags-catalog.md (repo-root).
Top flags for this skill:
This skill is gated by references/verification-gates.md (repo-root):
Evidence to surface: diff summary, classification table, updated learnings.json diff.
digraph fix_flow {
"User says 'fix'" [shape=doublecircle];
"Diff Figma vs snapshot" [shape=box];
"DS-compliant changes?" [shape=diamond];
"Hardcoded primitives?" [shape=diamond];
"Persist as LEARNING" [shape=box];
"Surface as FLAG" [shape=box style=filled fillcolor=lightyellow];
"Recipe eligible?" [shape=diamond];
"Auto-patch recipe" [shape=box];
"Update snapshot" [shape=doublecircle style=filled fillcolor=lightgreen];
"User says 'fix'" -> "Diff Figma vs snapshot";
"Diff Figma vs snapshot" -> "DS-compliant changes?";
"DS-compliant changes?" -> "Persist as LEARNING" [label="yes"];
"DS-compliant changes?" -> "Hardcoded primitives?" [label="check next"];
"Hardcoded primitives?" -> "Surface as FLAG" [label="yes"];
"Persist as LEARNING" -> "Recipe eligible?";
"Recipe eligible?" -> "Auto-patch recipe" [label="yes"];
"Auto-patch recipe" -> "Update snapshot";
"Recipe eligible?" -> "Update snapshot" [label="no"];
"Surface as FLAG" -> "Update snapshot";
}
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub noemuch/bridge --plugin bridge-ds5 skills in this plugin
/extracting-design-systemUse when the user says "setup", "setup bridge", "extract", "extract DS", "onboard", "build knowledge base", "initialize bridge", or is starting Bridge in a project for the first time. Handles the complete bootstrap: pre-flight checks, scaffolding (docs.config.yaml, cron workflow, .bridge/mcp.json), Figma token management (stdin-only), DS extraction via MCP (preferred) or REST (fallback), guide generation, and first commit proposal./generating-figma-designUse when the user requests to design, create, build, generate, or make a new Figma component or screen — including phrases like "make a button", "design a settings page", "build a new card", "generate X". Produces a CSpec, compiles it to a scene graph, executes it in Figma via MCP, and verifies the output./shipping-and-archivingUse when the user says "done", "ship it", "finish", "complete", "archive", or otherwise indicates the current design is ready to be shipped. Runs final verification (Gate B), archives the CSpec, updates history, extracts a recipe when eligible, and cleans up temp files./using-bridgeUse when any Bridge command is invoked (make, fix, done, setup, drop, status) or any Figma / design-system / compiler / Bridge workflow topic is raised. Sets command priorities and iron laws (compiler-only, semantic tokens only, verification-before-ship).Other plugins' skills for the same job