happy-sim-scaffold
Generate a complete simulation from a high-level description
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Generate a complete simulation from a high-level description
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Run ruff linter and formatter on the project
Add observability (probes, trackers, charts) to a simulation
Analyze simulation results and provide insights
Help choose the right happysimulator components for a use case
Troubleshoot a broken or misbehaving simulation
Walk through a library example with detailed explanation
| name | happy-sim-scaffold |
| description | Generate a complete simulation from a high-level description |
Generate a complete, runnable happysimulator simulation from a user's description.
If the user hasn't described what they want to simulate, ask them. Get enough detail to choose the right components (e.g., "a hospital ER with triage" vs "a generic queue").
Read the project's CLAUDE.md for the full API reference, conventions, and component catalog. Use it as your source of truth for imports, patterns, and available components.
Generate a single .py file with this structure:
"""<Title>: <one-line description of what this simulates>."""
from dataclasses import dataclass
# ... imports from happysimulator ...
@dataclass(frozen=True)
class Config:
"""Simulation parameters."""
# All tunable knobs here with sensible defaults
# Entity classes with handle_event / handle_queued_event generators
def run(config: Config | None = None) -> None:
config = config or Config()
# Build pipeline: sink ← server(s) ← source
# Create Simulation with sources, entities, end_time
# Run and print summary
if __name__ == "__main__":
run()
Follow these conventions strictly:
Instant.from_seconds(n), never raw floats for Event timestarget. Use Event.once() for function-based dispatchyield <float> for delays, yield <float>, [events] for delay + side-effects, yield <future> to park, return [events] on completionSimulation(entities=[...])has_capacity() if you want the queue to actually build upSink or Counter and print sink.latency_stats() or counter.total at the endseed=42 on distributions and random.seed(42) for reproducibilityPrefer built-in components over custom entities when possible:
Source.poisson(rate=N, target=server) for stochastic arrivalsSource.constant(rate=N, target=server) for deterministic arrivalsQueuedResource for anything with a queue + processingSink / Counter for collecting resultsConveyorBelt, BatchProcessor, ShiftSchedule, etc.) for operations researchNetwork + link conditions for distributed systemsAgent + Population for behavioral modelingRun the generated file with python <file> to verify it works. Fix any errors.
Briefly explain the simulation structure to the user: what entities exist, how events flow, and what metrics are printed.
| Domain | Key Components |
|---|---|
| Queuing | QueuedResource, FIFOQueue, PriorityQueue, Sink, Counter |
| Networking | Network, datacenter_network(), internet_network(), partition() |
| Rate limiting | RateLimitedEntity, TokenBucketPolicy, Inductor |
| Resilience | CircuitBreaker, Bulkhead, TimeoutWrapper, Fallback, Hedge |
| Industrial | ConveyorBelt, InspectionStation, BatchProcessor, ShiftSchedule, BreakdownScheduler, InventoryBuffer, BalkingQueue, RenegingQueuedResource, GateController, SplitMerge, PreemptibleResource |
| Storage | KVStore, LSMTree, WriteAheadLog, TransactionManager |
| Distributed | RaftNode, PaxosNode, CRDTStore, DistributedLock |
| Behavioral | Agent, Population, Environment, SocialGraph |
| Resources | Resource (contended capacity with acquire/release) |
| Load balancing | ConsistentHashRing, RoundRobinBalancer, LoadBalancer |