← ClaudeAtlas

synapse-action-developmentlisted

Explains how to create Synapse plugin actions. Use when the user asks to "create an action", "write an action", uses "@action decorator", "BaseAction class", "function-based action", "class-based action", "Pydantic params", "ActionPipeline", "DataType", "input_type", "output_type", "semantic types", "YOLODataset", "ModelWeights", "pipeline chaining", or needs help with synapse plugin action development.
datamaker-kr/synapse-claude-marketplace · ★ 1 · AI & Automation · score 55
Install: claude install-skill datamaker-kr/synapse-claude-marketplace
# Synapse Action Development Synapse SDK provides two patterns for plugin actions: **function-based** (simple, stateless) and **class-based** (complex, stateful). ## Quick Start: Function-Based Action ```python from pydantic import BaseModel from synapse_sdk.plugins.decorators import action from synapse_sdk.plugins.context import RuntimeContext class TrainParams(BaseModel): epochs: int = 10 learning_rate: float = 0.001 @action(name='train', description='Train a model', params=TrainParams) def train(params: TrainParams, ctx: RuntimeContext) -> dict: for epoch in range(params.epochs): ctx.set_progress(epoch + 1, params.epochs) return {'status': 'completed'} ``` ## Quick Start: Class-Based Action ```python from pydantic import BaseModel from synapse_sdk.plugins.action import BaseAction class InferParams(BaseModel): model_path: str threshold: float = 0.5 class InferAction(BaseAction[InferParams]): action_name = 'inference' def execute(self) -> dict: self.set_progress(0, 100) # Implementation here return {'predictions': []} ``` ## When to Use Each Pattern | Criteria | Function-Based | Class-Based | |----------|----------------|-------------| | Complexity | Simple, single-purpose | Complex, multi-step | | State | Stateless | Can use helper methods | | Semantic types | Limited | Full support | **Recommendation**: Start with function-based. Use class-based when needing helper methods or semantic type declara