Component Patterns
Reference documentation for building Prismatic custom components.
<disallowed-tools> Do NOT use these MCP tools — they return incomplete data that causes broken scaffolds and missing connections downstream. A hook will deny them, but avoid the wasted round trip.mcp__prism__prism_components_list— Userun.ts find-components <keyword>insteadmcp__prism__prism_components_init— Userun.ts scaffold-componentinsteadmcp__prism__prism_components_publish— Userun.ts publish-componentinsteadmcp__prism__prism_components_generate_manifest— Manifests are auto-generated during scaffoldingmcp__prism__prism_install_component_manifest— Handled byrun.ts scaffold-project --componentsmcp__prism__prism_install_legacy_component_manifest— Handled byrun.ts scaffold-project --components</disallowed-tools>
Architecture Patterns
Connector Components
- Wrap external APIs (Salesforce, Canny, HubSpot, etc.)
- Support OAuth2, API Key, Bearer Token, Basic Auth
- Define connections, actions, triggers, and data sources
- Installed via Prism CLI
Utility Components
- Provide helper actions (data transformation, formatting, etc.)
- No external connections needed
- Define only actions with typed inputs
Config Mantra
Components define their own inputs — not configVar() wrappers. Each action uses input() definitions directly:
input()for typed action inputs (label, type, required, comments, default)connection()for auth field definitions (key, label, inputs)- Use
util.typesfor input type constants - See
references/authentication-patterns.mdfor connection field patterns
Phase: API Research
When the on_answer trigger fires for api_docs_url, the agent spawns the external-api-researcher
agent with the URL. The researcher fetches and analyzes the API docs, producing a structured JSON
spec at {session_dir}/api-research.json. The component builder waits for results before proceeding.
- See
references/api-research-guide.mdfor the output format and research strategies - Research results inform
auth_type,confirm_resources,webhook_support,base_url
Phase-Specific References
Load only the references relevant to your current workflow phase. This keeps context focused and avoids attention budget waste.
Phase 2: Requirements Gathering
- Spec items carry
agent_context(narration backbone),implications(per-option consequence maps), anddocs(Prismatic doc URLs). The agent uses these inline — no external references needed for most questions. Docs are fetched on demand only when agent_context is insufficient or the user asks a follow-up beyond what the curated content covers. references/api-research-guide.md- How to research external APIs (load whenapi_docs_urlis answered)
Phase 3: Scaffold
references/component-architecture.md- Component directory structurereferences/spectral-component-quickstart.md- Spectral SDK basics
Phase 4: Code Generation (PRIMARY PHASE)
See the <spec-loading> block in component-builder.md for progressive disclosure rules.
The references below are the full set available — load per the agent's guidance.
references/answer-to-code-cookbook.md- LOAD FIRST — Maps component.yaml answers directly to TypeScript code snippets. Spec items withcookbook_sectionfields point to specific headings in this file — Grep for those headings to find exact patterns, especially after context compaction.references/code-generation-guide.md- File generation patterns and component structurereferences/authentication-patterns.md- API Key, OAuth2, Bearer Token, Basic Auth patterns- Templates:
${CLAUDE_PLUGIN_ROOT}/templates/component/- Structural templates for all source files
Conditional references for Phase 4 (load based on requirements):
- If webhook triggers:
references/trigger-patterns.md- Webhook trigger lifecycle and implementation - If polling triggers:
references/trigger-patterns.md- Polling trigger withpollingTrigger(),context.pollingstate management - If OAuth2 auth:
references/oauth2-connection-guide.md- Deep dive on OAuth2 connections (useoauth2Connection()from spectral, NOTconnection()) - If data sources:
references/data-source-patterns.md- Data source implementation patterns - Always for connectors:
references/client-patterns.md- HTTP client helper patterns
Phase 5: Build & Publish
references/troubleshooting-errors.md- Build/publish failure solutions
Examples (consult during code generation)
references/examples/utility-component/- Complete utility examplereferences/examples/apikey-connector/- Connector with API Key authreferences/examples/oauth2-connector/- Connector with OAuth2 auth
All References
Full reference list for manual lookup:
references/answer-to-code-cookbook.md- Maps component.yaml answers to TypeScript codereferences/api-research-guide.md- How to research external APIsreferences/component-architecture.md- Component directory structurereferences/code-generation-guide.md- File generation patternsreferences/authentication-patterns.md- API Key and OAuth2 patternsreferences/oauth2-connection-guide.md- Deep dive on OAuth2 connectionsreferences/spectral-component-quickstart.md- Spectral SDK basicsreferences/trigger-patterns.md- Webhook trigger lifecyclereferences/data-source-patterns.md- Data source patternsreferences/client-patterns.md- HTTP client helper patternsreferences/troubleshooting-errors.md- Build/publish failure solutionsreferences/examples/utility-component/- Complete utility examplereferences/examples/apikey-connector/- Connector with API Key authreferences/examples/oauth2-connector/- Connector with OAuth2 auth
Component Key Patterns
- Function-based client:
createClient(connection, debug)returningHttpClientfrom spectral — NOT class-based - Error hook: Every component MUST include
hooks: { error: (error) => { ... } }— re-throwConnectionErroras-is, wrap others innew Error() - rawRequest action: REQUIRED in every component at
actions/misc/rawRequest.ts - Folder-based structure:
actions/<resource>/,inputs/,examplePayloads/,dataSources/,triggers/ - examplePayload: Every action must have one, imported from
src/examplePayloads/, verified against API - Clean functions: Every non-connection input needs
clean: util.types.toString(or toBool, toNumber, etc.) - Input requirements:
comments,placeholder,exampleon every string input - Data source elements:
{ label, key }format (NOT{ label, value }) — type isElementfrom spectral - Debug wiring:
context.debug.enabled→createClient(connection, debug)in actions,falsein lifecycle hooks - ConnectionError: Thrown in client.ts for connection type mismatches, NOT in actions
- Webhook URL:
context.webhookUrls[context.flow.name]in lifecycle hooks - Connection keys: Simple names (
"apiKey","oauth2") — NOT"component-api-key" - Action return: Always
{ data: <result> }. DataSource return:{ result: Element[] }