/desflow:desflowfrom desflow
Write, check, test and run desflow discrete-event simulation models in YAML, the builder API or the low-level API, and port SimPy programs to them.
Ships in desflow. 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.
Read when SKILL.md points to them; scripts run unread.
desflow runs SimPy simulations whose parameters can change while they run, and writes the events and telemetry to the console, Kafka, Parquet or JSONL files, Iceberg, PostgreSQL or Redis. A model can be written in three ways, and all three give the same records.
Read each reference page, asset and script at the exact path given below, with nothing added. Claude Code fills in the first part of the path with the folder that holds this file; in a tool that does not fill it in, that first part stands for the same folder.
| Way | Use it when |
|---|---|
| YAML blueprint | The model is resources, services, arrivals and tasks. Start here. A blueprint is checked as a whole before anything runs, and an error names the file and line. |
| Builder API | The model is mostly a blueprint, but the file needs logic in Python, such as a payload function or a process. SimulationContext has one method for each blueprint section. |
| Low-level API | The model needs SimPy itself, with desflow's resources, clocks and sinks. |
A blueprint can also call Python with !python module.attribute, so a model rarely has to leave YAML. A file that references Python runs the imports it names, so treat it like a script.
desflow examples list and desflow examples get <name> --api yaml. The example files match the installed version.simulation is required. references/blueprint-keys.md lists every key, and assets/blueprint.schema.json is the JSON Schema of a blueprint for editors and checkers.desflow run <file>. Add --until 10min to stop earlier and --seed 7 to repeat a run. An invalid file prints every error with its file and line and exits with code 1.desflow schema prints the same JSON Schema as ${CLAUDE_SKILL_DIR}/assets/blueprint.schema.json, for the installed version.
Use these steps when the user describes a process in words and has no model yet.
desflow examples list, then desflow examples get <name> --api yaml.assumed: and what was assumed. Put the assumed numbers first in your reply, because the user must confirm them.desflow explain gives no estimate, as it does for a model with scenario steps or a task that routes on a variable. The work for one case is the sum of its task times, counting a branch by its share and a rework loop by how often it repeats. That work, times the arrival rate, must fit inside the capacity of the working hours. If it does not, the queue grows without limit, and the user should hear that before anything runs.next: {when: [{condition: 'registry["Shop.variables.open"] == 1', task: first_task}]}. An arrival that comes while the desk is closed ends there.desflow run <file> --sample 10. It prints the first 10 events as JSON lines, unpaced, with no ingress and no real sinks, so a model that writes to Kafka or a database needs no service. <file> is a blueprint or a builder Python file, and desflow check <file> takes both too.desflow explain <file>. It takes a blueprint or a builder Python file with a module-level SimulationContext, and shows the model as a graph with each resource's utilisation, status, waits and tuning hints where the queueing formulas apply, and why where they do not. A resource at utilisation 1 or above is UNSTABLE: its queue grows for as long as the run lasts.--verify to also run the model unpaced and compare its statistics with the analysis, within 10 percent for one run, or with each measure's 95% interval with --replications N.To give a service a measured mean and standard deviation, desflow dist <family> --mean <mean> --std <std> converts them to the family's parameters, such as desflow dist gamma --mean 1.5 --std 0.4832, and prints them in YAML and Python. desflow dist alone lists the families.
Copy this checklist into your reply and tick each line as it is done:
- [ ] List every behaviour the request names, one line each.
- [ ] For each, name the key or the code that makes it, and the record that shows it.
- [ ] Run python "${CLAUDE_SKILL_DIR}/scripts/check_model.py" <files>; fix every line it prints; run it again.
- [ ] Find each listed record in the output of desflow run <file> --sample 50.
- [ ] Read each header, docstring and comment against that output.
scripts/check_model.py is in this skill's folder. Run it, do not read it: python "${CLAUDE_SKILL_DIR}/scripts/check_model.py" model.yaml builder.py low_level.py [--until T], with one, two or three forms in any order. It runs each Python file as python FILE, unpaced, with its sinks replaced by a JSON console, and sets and reads each form's seed through desflow. It sees only the process python FILE starts, so each Python file builds and runs its model in that process, not a child process. It reports:
desflow check refuses;random, which makes two runs at one seed differ;Sampler;desflow test on the YAML, and on a Builder file that has a tests.yaml beside it.A seed is found where it is given to random.Random, random.seed, numpy.random.seed, RandomState, default_rng, SeedSequence or a NumPy bit generator. A state set another way (setstate, the state setter, unpickling), a SeedSequence with a spawn key, a seeding function called through functools.partial or another callable with no Python code of the model's, a generator the model writes itself and one a C extension seeds are not found, and the rule to draw only through desflow still applies to them. Each line it prints names the file and line and what to write instead. It does not look for private attributes such as app._sinks: check those yourself against the rule below.
scenario adds two agents at 1 hour.", checked against --sample.count over last: 10 with no where, which is 10 in every report. Right: a where that counts the large orders.history, a tolerance. Wrong: until: 1001. Right: until: 1001 # one second past the last report at 1000, so it is published.env.trace_events() gives the trace".desflow test and the records with pytest.logical_start_time. A record's timestamp is not the wall-clock time: it is logical_start_time plus the simulation time, so with a fixed start time two runs give the same timestamps.| Section | What it holds |
|---|---|
simulation | Required. The simulation id, pacing factor, random seed, time zone, warm-up and clock. |
resources | Named resources with a capacity, a queue order, preemption and breakdowns. |
containers | Named containers that hold a continuous amount. |
stores | Named stores that hold items. |
services | Named distributions that give how long a task step takes. |
arrivals | When entities arrive: a distribution or a replay of recorded rows, and the task each one starts. |
variables | Values that expressions and tasks read and that a run can change. |
signals | Named events that tasks fire and wait for. |
tasks | What an entity does: wait, request a resource, take or put an amount, pass the time, then go to the next task. |
telemetry | Custom readings published at a fixed interval. |
processes | Python functions that run beside the tasks, named with !python. |
scenario | Changes to a parameter at set times in the run, and records of what was true then. |
ingress | Where parameter changes come in from: Local, File, Kafka, Postgres or Redis. |
egress | Where records go out to: Console, Kafka, Parquet, Jsonl, Iceberg, Postgres or Redis. |
batching | How records are grouped before they are sent. |
stats | Which built-in statistics are published, and how often. |
run | How long the run lasts, whether to drain at the end, and functions to call before it starts. |
tests | Named checks that desflow test runs: a seed, a run length and the measures expected. |
mean: 4 min, not mean: 240. The Low-level DistributionConfig takes seconds only, so give the unit in a comment: DistributionConfig(dist="normal", mean=240, std=60) # 4 min, 1 min. rate is a number per second. A SimPy program that counts minutes is ported with each time converted, or says once that one SimPy minute is one second here. references/simpy.md lists the other differences from SimPy.from desflow import ... and from desflow.values import ... give (references/api.md) and the documented serializer classes. Wrong: resource._capacity = 3 or from desflow.builder.task import NO_RECORD. Right: env.registry.update("Shop.resources.packers.current_cap", 3) and from desflow import NO_RECORD.sampler.sample(env.registry.get_config("<sim_id>.<path>")), which draws from the path's own sequence, and each generated value from sampler.generator("<place>"), such as sampler.generator("tasks.audit.payload.merchant"), with the same seed. Use the generator's methods: rng.uniform(-1, 1), not -1 + 2 * rng.random(). A DistributionConfig built by hand and never registered draws from the main generator and gives other numbers.python <file>: use ConsoleEgress(format="json"), or call logging.basicConfig(level=logging.INFO) before the run, because the default log format writes at INFO. Import a connector that needs an extra only in a file whose header names that extra. A YAML Console prints JSON lines with {type: Console, config: {format: json}}.lookup or aggregate reads; give the same history in both or none. A Builder task read only from a Template keeps none: give it history=.logical_start_time and go_live_at are instants: now, a signed duration such as -1d, or an ISO datetime.!python module.attribute imports the module and returns the attribute. The module is found on sys.path, which includes the folder of the YAML file, so a Python file beside the blueprint works from any directory.!include path puts a mapping from another YAML file in place, with the path relative to the file that names it.${VAR} reads an environment variable and ${VAR:-default} gives a default when it is unset or empty. An unquoted value is read as YAML reads it after the replacement, so factor: ${SIM_FACTOR:-0} is the number 0. $${ writes a literal ${. A variable without a default that is unset stops the load.spawn names one task. The task passes the entity on with next. In the Builder, a task that an arrival's spawn starts takes task_id, and entity, upstream, item or wait only when it declares them, such as def pack(task_id, entity):. It takes no context; only an arrival_loop function does.spawn and an on: spawn action start a task as a new entity. A task that a task's spawn or an on: spawn starts must not share an arrival's name.type is a short name with its capital letter, such as Console or Kafka. references/connectors.md lists them and the extra each one needs.One run is one sample. To report a result, run a study.
simulation.random_seed, or pass --seed, so the run can be repeated.simulation.warmup to the time the model needs to reach its usual state. The statistics start again from zero at that time, so the start of the run is left out of them.desflow run <file> --replications 20. Each replication has its own seed, spawned from the seed.--level changes it. When a program or a file must hold the figures, add --summary <file.json>: it writes the seeds, each statistic's mean, half_width, low and high under summary, and each replication's value under results. Read the figures from that file instead of the printed table.desflow experiment <file>. It runs every design with the same seeds, compares them, checks bounds, and writes its files and report.md. It exits 1 when a check fails. desflow report <folder> builds the report again from the files.To give a service measured times, desflow fit <file.csv> --column <name> --lower 0 --out <fit.yaml> fits every family and writes the best as YAML for !include. It needs the fit extra.
Command Line uses every command on one shop. Read Replications, Experiments, Randomness and Seeds and Trusting Results before choosing the warm-up and the number of replications.
desflow command, with every option.desflow exports, with what it is and the extra it needs.The documentation is at https://jaehyeon.me/desflow/latest/. Its pages are also available as plain text at https://jaehyeon.me/desflow/latest/llms.txt and https://jaehyeon.me/desflow/latest/llms-full.txt.
assets/blueprint.schema.json (opens in a new tab)references/api.md (opens in a new tab)references/apis.md (opens in a new tab)references/blueprint-keys.md (opens in a new tab)references/cli.md (opens in a new tab)references/connectors.md (opens in a new tab)references/distributions.md (opens in a new tab)references/simpy.md (opens in a new tab)references/testing.md (opens in a new tab)scripts/check_model.py (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub jaehyeon-kim/desflow --plugin desflow