Codebase Scanner
The scanner reads your repository for React components and Storybook stories, then syncs them to your Layout project. Scanned components appear alongside Figma components in the Design System hub and feed into Explorer prompts, so the agent reuses what you already have instead of re-generating it.
What gets detected
- React components — function exports, const exports,
forwardRef, grouped exports, default exports. Props interfaces are resolved. - Storybook stories (CSF3) — story names, tags,
argTypes, andargsare parsed so the agent knows the variants you already support. - Import paths — resolved using the
@/alias convention so generated code can import your components cleanly.
get_component and list_components MCP tools. Coming in a follow-up.Setup
The scanner is part of the Layout CLI. After you've run init and install, run the scan from the root of your repository:
npx @layoutdesign/context scan --sync --project <projectId>You'll find the project ID in the Studio URL after opening a project. The --sync flag pushes scanned components to Layout; without it, the command is a dry run.
Flags
| Flag | Default | Description |
|---|---|---|
| [path] | cwd | Directory to scan. Defaults to the current working directory. |
| --sync | off | Push results to Layout. Without it, the scan prints locally. |
| --project <id> | — | Layout project to sync into. Required with --sync. |
| --type <t> | all | Limit to components or stories. |
Auto-scan on MCP start
When your AI agent starts the Layout MCP server, the scanner runs automatically on the linked project root. Typical runs finish in 10–30 ms. You don't have to invoke scan manually for the agent to see your components.
scan --syncexplicitly when you want scanned components to show up in the Studio UI. The MCP-side scan feeds the agent but doesn't push to the Layout API.Where scanned components show up
- Design System hub → Components view — merged with extracted Figma components so you see both sources side by side.
- Source Panel → Components tab— shows an empty state with setup instructions on projects that haven't been scanned yet.
- Explorer prompt context — scanned components are injected into the Component Inventory section so the agent can import rather than rebuild.
- MCP —
list_componentsmerges design system + codebase sources;get_componentreturns whichever has more detail.
Auto-rescan on push
Configure a GitHub webhook pointing at your Layout project. On every push, the scanner re-runs against the updated tree and the component list refreshes automatically. Add or rename a component, push, and it shows up in Layout without a manual sync.
Known limits
- Storybook
argTypes,args, and story names are parsed but not yet exposed viaget_componentorlist_components. Coming soon. - Figma-to-code name matching uses normalised substring matching. Exact matches always win, but loose matches can surface unexpectedly. Rename Figma components closer to your code for best results.
- Icon-style components (e.g.
icon/alert-circlein Figma) can flood the merged list when the Figma file ships a large icon set. Filter by type in the Components view to focus on UI components.
Related
- Layout CLI
- Webhooks — auto-rescan on every push.
- Saved Components — the Explorer-side library, distinct from codebase-scanned components.