explain-dataset-fsr
Helps users of the Timefold Field Service Routing (FSR) model understand an optimized route plan by fetching and interpreting the dataset via the API. Use this skill whenever someone asks why visits a
SKILL.mdskills/explain-dataset-fsr/SKILL.md
GitHubModel context: Field Service Routing (FSR)
Terminology
| Generic term | FSR term |
|---|---|
| Work item / work unit | visit |
| Resource | vehicle |
| Resource sub-unit | vehicle shift (a vehicle can have multiple shifts) |
| Mandatory work | mandatory visit |
| Optional work | optional visit |
| Required capability | skill (requiredSkills) |
| Capacity constraint | shift time window (maxEndTime), max visits, max travel time |
Model-specific configuration
Always set these before running any script.
MODEL=field-service-routing
MODEL_API_URL=https://app.timefold.ai/api/models/field-service-routing/v1
COLLECTION=/route-plans
OPENAPI_URL=https://app.timefold.ai/openapis/field-service-routing/v1
Scripts
Scripts live in the sibling skill explain-dataset-shared, in its scripts/ directory.
Anchor every path on this skill's own directory, not on the working directory. The working
directory is the user's project, and these skills are installed somewhere else.
In Claude Code, ${CLAUDE_SKILL_DIR} is substituted with this skill's directory. If your agent
leaves the placeholder unresolved, replace it with the absolute directory that holds this
SKILL.md.
$PY is the Python runner that the shared skill's runtime check selects (uv run,
python3, or python). Run that check before the first script call.
The variables in the block below are placeholders. Write their values out in every command you
run, with the runner and the absolute script path in full, for example
uv run /abs/path/to/explain-dataset-shared/scripts/summarize.py --model-api-url https://... --model ....
Each command starts a new shell, so a variable that an earlier command set is gone. And in zsh,
the default shell on macOS, $PY with the value uv run stays one word, so the command is not
found.
SKILL_DIR=${CLAUDE_SKILL_DIR}
SHARED=$SKILL_DIR/../explain-dataset-shared
SCRIPTS=$SHARED/scripts
PLUGIN_ROOT=${CLAUDE_PLUGIN_ROOT:-$SKILL_DIR/../..}
$PY $SCRIPTS/summarize.py --model-api-url $MODEL_API_URL --model $MODEL --dataset-id ID [--tenant ID]
$PY $SCRIPTS/list_unassigned.py --model-api-url $MODEL_API_URL --model $MODEL --dataset-id ID [--recommendations]
$PY $SCRIPTS/resource_metrics.py --model-api-url $MODEL_API_URL --model $MODEL --dataset-id ID [--sort overtime|travel|visits|name]
$PY $SCRIPTS/work_details.py --model-api-url $MODEL_API_URL --model $MODEL --dataset-id ID --work-ids "visit-001"
$PY $SCRIPTS/work_details.py --model-api-url $MODEL_API_URL --model $MODEL --dataset-id ID --resource "VAN-12"
$PY $SCRIPTS/score_violations.py --model-api-url $MODEL_API_URL --model $MODEL --dataset-id ID [--type hard|medium|soft]
$PY $SCRIPTS/score_justifications.py --model-api-url $MODEL_API_URL --model $MODEL --dataset-id ID [--samples 3]
$PY $SCRIPTS/score_justifications.py --model-api-url $MODEL_API_URL --model $MODEL --dataset-id ID --resource "VAN-12"
$SHARED also carries the version stamp and, in a plugin install, $PLUGIN_ROOT carries the
plugin manifest. The report metadata needs both. Keep the two variables set.
API
Base URL : https://app.timefold.ai/api/models/field-service-routing/v1
Auth : X-API-KEY: {token}
Collection path: /route-plans
OpenAPI spec: https://app.timefold.ai/openapis/field-service-routing/v1
Documentation
- User guide: https://docs.timefold.ai/field-service-routing/latest/
- Metrics and KPIs: https://docs.timefold.ai/field-service-routing/latest/metrics-and-optimization-goals
FSR-specific notes
- Unassigned visits are in
modelOutput.unassignedVisits(an explicit list of visit IDs), not inferred from a null field like in ESS. - Vehicles have shifts: a vehicle wraps one or more
vehicleShiftobjects that each have their own itinerary, time window, and metrics. Per-vehicle aggregate metrics are invehicle.metrics; per-shift detail is invehicle.shifts[].metrics. - Travel metrics are a core KPI: total travel time, distance, average per visit, and time breakdowns (depot-to-first, between visits, last-to-depot).
- SLA: if
percentageVisitsInSla/absoluteVisitsInSlaare present, call them out. They directly measure service quality. - Mandatory vs optional is not a fixed tag or priority range. By default, this is automatic
and implicit: a visit is mandatory if its time window falls within the current planning
window, and optional if its time window ends outside it. The
priorityfield can override this default: built-in priorities1-10use the automaticAUTObehavior above (overridable dataset-wide viadefaultAssignmentType: MANDATORY),opt-1-opt-10are always optional, and custom priority names can set an explicitassignmentofAUTO,MANDATORY, orOPTIONAL. Read the dataset's own priority configuration rather than assuming a fixed threshold. See Priority visits and optional visits. SOLVING_COMPLETEDis not a feasibility verdict. It means the solver stopped. A completed plan with a negative hard score is infeasible.
Hard constraints: the settings behind them
The shared skill tells you to trace every hard violation to the settings that cause it, and to link each one. This table maps the FSR hard constraints that are hardest to trace to the input field or configuration setting that switches them on.
| Constraint | Switched on by | Docs |
|---|---|---|
| Require visit dependency prerequisite assigned | visits[].visitDependencies[].precedingVisit on B. Penalizes B being assigned while A, its preceding visit, is unassigned |
Single visit dependency |
| Require visit dependency dependent assigned | A dependency whose assignment type is DISALLOW_TO_BLOCK_FOLLOWING (the default, also set dataset-wide by defaultDependencyAssignmentType) |
Assignment type |
| Require visit dependency delay | minDelayTo / maxDelayTo on the dependency |
Dependency with delay |
| Require the same vehicle for dependent visit | coordination: SAME_VEHICLE on the dependency |
Coordination |
| Require the same vehicle shift for dependent visit | coordination: SAME_SHIFT, or any pooling type other than ALLOW_POOLING_ALL, set on the dependency or inherited from config.model.overrides.defaultDependencyPoolingType |
Coordination, Pooling type |
| Require visit dependency pooling type | poolingType other than ALLOW_POOLING_ALL, on the dependency or from defaultDependencyPoolingType |
Pooling type |
| Keep a pinned visit's vehicle shift | pinningRequested: true on the visit, or pin: true on an itinerary item |
Pinning individual visits |
| Keep a pinned visit's start service time | pin: true with startServiceTime on vehicles[].shifts[].itinerary[] |
Pinning individual visits |
For a hard constraint that is not in this table, find its page in the FSR user guide before you explain it. Don't link a URL that you did not open.
Visit dependencies: what each part means
- A plain dependency only orders the visits. With only
precedingVisit(and optionally a delay), B starts no sooner than A ends, and B is not assigned unless A is. A and B can be on different vehicles and on different days. A plain dependency does not mean "same vehicle" or "same shift". - A pooling type other than
ALLOW_POOLING_ALLimplicitly addsSAME_SHIFT. Pooling controls whether other visits can sit between A and B. When the pooling type isALLOW_POOLING_VISITS,ALLOW_POOLING_DEPENDENCIES, orDISALLOW_POOLING, the model sets the dependency's coordination toSAME_SHIFT(unless it is alreadySAME_SHIFT_ENFORCE). The input record then shows nocoordinationfield, yet the "same vehicle shift" constraint still applies. - The pooling type often comes from the dataset default. A dependency without its own
poolingTypetakesconfig.model.overrides.defaultDependencyPoolingType.summarize.pyprints it under "Configuration overrides". At level 3 or 4, read it fromGET {collection}/{id}/config.
Known conflict: recurring visits chained with dependencies
Recurring work (a weekly visit for four weeks) is often modeled as a dependency chain, so that week 2
is not planned without week 1. That is a valid use of a plain dependency. It breaks when the
dependencies get SAME_SHIFT, because visits on different dates can never share one vehicle shift.
If the visits are also pinned to their dated shifts, the solver cannot move them, and every link
in the chain stays a hard violation of "Require the same vehicle shift for dependent visit".
Explain it as three settings that combine, each with its docs link: the dependency chain, the
pooling type that implies SAME_SHIFT, and the pinning. The fix that keeps the user's intent is
poolingType: ALLOW_POOLING_ALL on those dependencies, or as the dataset default if no other
dependency needs a stricter pooling type. Do not propose to remove the dependencies: that drops the
"week 2 only after week 1" rule.
Before Step 0: Check that the dataset is an FSR dataset
If the user gave a platform URL, read the model from its path, the segment after /models/.
This skill only handles field-service-routing. For any other model, stop before the questions
and don't call the API. Tell the user which model the link belongs to and which skill to use:
| Path segment | Skill to use |
|---|---|
employee-scheduling |
/explain-dataset-ess |
pickup-delivery-routing |
/explain-dataset-pdr |
For a model that isn't in this table, say that no explain-dataset skill covers it yet. If the
user gave a bare dataset ID, you can't tell the model from it; go ahead, and if the FSR API
answers HTTP 404 for that ID, tell the user the dataset probably belongs to another model and
ask for the platform URL.
Step 0: Ask who the output is for
Before anything else, including the runtime check and the credentials in Step 1, ask the user
three questions. Ask all three at once, with the AskUserQuestion tool if it is available,
otherwise as one numbered message in the chat. Skip a question only when the user already
answered it in their request (for example "explain this for a dispatcher, in Dutch").
Open with one sentence that says why you ask: "Before I look at the route plan, three quick
questions so the explanation fits the person who will read it." Change the count when you
skip a question. Then use the question and option texts below. With AskUserQuestion, put
the question text in question and the option text in description.
Who will read this explanation? Question text: "Who will read this explanation? I'll match the wording, the technical depth, and the references to that person."
- Planner or dispatcher. "Someone who builds or approves the route plan. They get plain language about visits, technicians, travel, and time windows, and concrete changes to make in the plan. No constraint names or settings fields. Scores only in plain words."
- Support or implementation consultant. "Someone who helps a customer configure or tune the model. They get the same plain explanation, plus the name of each constraint involved, the input setting to change, and a link to the matching docs page."
- Developer or integrator. "Someone who builds the integration or debugs the model input. They get everything above, plus exact fields and values, the score breakdown, and a log of every API call the analysis made, so they can reproduce it."
Skip this question when the request names the reader (for example "explain dataset X for a dispatcher"). Otherwise, guess the reader from the request, put that option first, and add "(Recommended)" to its label:
- A dataset ID or URL with a question such as "why is visit X unassigned": support or implementation consultant.
- A pasted JSON payload, a score string, or input field names: developer or integrator.
- Plain operational wording such as "why does Ben have no visits on Tuesday": planner or dispatcher.
- No clear signal: keep the order above and mark no option.
How much detail do you want by default? Question text: "How much detail do you want to start with? You can always ask for more afterwards."
- Full breakdown (recommended). "A complete report saved as a file: every problem found, all proposed fixes ranked by confidence, and the supporting data behind them. Best when you want to share it or keep it."
- Short summary. "The coverage result and the three biggest problems, each with the most likely fix, shown here in the chat. Ask for the full report or a deeper look at any problem when you need it."
Which language should the explanation be in? Question text: "Which language should I write the explanation in? Technical terms such as constraint names, IDs, and links stay in English."
- English. "Written in US English."
- Dutch. "Written in Dutch, with 'bezoek' for visit and 'technicus' for technician."
- German. "Written in German, with 'Einsatz' for visit and 'Techniker' for technician."
- French. "Written in French, with 'intervention' for visit and 'technicien' for technician."
- Other. "Name the language, and I'll write in that one." If the user picks Other without
naming a language, ask which one. With
AskUserQuestionthis option comes built in; don't add it yourself.
Keep the answers for the whole conversation. Don't ask again for follow-up questions about the same dataset. Don't ask again for a second dataset either; confirm in one line that the same settings apply. If the user changes an answer later, apply the new setting from that point on.
The rules below override the shared instructions where the two disagree.
Audience
In FSR input a technician is a vehicle. For the planner audience, say "technician" (or the
customer's own word, if the input names make it clear) and never "vehicle shift".
| Planner or dispatcher | Support or implementation consultant | Developer or integrator | |
|---|---|---|---|
| Wording | Plain operational language | Plain language first | Plain language first |
| Constraint names | Never | In backticks after the plain description, e.g. "technicians work past their shift end (<constraint name>)" |
Yes |
Field paths and JSON (e.g. vehicles[].shifts[].skills) |
Never; describe the setting instead ("the skills on the technician's shift") | Yes, in proposals | Yes |
| Doc links | Only the user guide link, once | One link per bottleneck to the matching constraint page | One link per bottleneck to the matching constraint page |
| Score string and score levels (hard, medium, soft) | Only in plain words, for example "the plan still breaks 3 rules that must hold"; no score string | Only in Appendix A, translated | Yes, in Appendix A |
| Appendix B (API audit log) | Leave out | Leave out | Include |
| Proposals | What to change in the plan or the input, in planner terms | The setting or input field to change, and where in the platform | The exact field and value, and the API call that would confirm it |
For the planner audience, the deep-dive offer at the end also stays in planner terms: talk about visits, technicians, travel, and time windows, not about constraints or recommendations endpoints.
Add one bullet to the report metadata block, after Requested scope:
- Audience:
<persona>,<detail level>,<language>
Detail level
- Short summary. Show the result in the chat only: the platform links, the coverage
headline, and the three bottlenecks with the highest impact, each with its proposal of highest
confidence. Leave out the appendices. Then make the deep-dive offer, and add one line that
offers the full report. Write the report file (through
timefold-write-report) only when the user asks for the full report. - Full breakdown. Follow the shared instructions: the full report with all bottlenecks and proposals, and the appendices that the audience table allows.
Choosing a detail level already answers whether to save a file, so don't ask that again. When you
save the report (full breakdown, or a short summary where the user asked for the full report), don't
ask where either. Save it to reports/field-service-routing/explain-dataset/ under the working
directory, and create the folder if it doesn't exist. Use the filename pattern from the shared
instructions. Give the user the full path afterwards, and move the file only if they ask. If the
user named another location earlier in the conversation, or you have a stored preference for one,
use that instead.
Language
English. Follow the
language-guidelinesskill as the shared instructions say.Any other language. Write all prose in that language: the chat summary, the headings, the bottleneck and proposal text, the metadata labels, and the deep-dive offer. Keep these untranslated: constraint names, field names, IDs, URLs, the
[IMPACT: …]and[Confidence: …]tags, and the report filename. Oflanguage-guidelines, keep the rules that do not depend on English (active voice, no em dashes, short sentences) and drop the English-only ones (US spelling, serial commas, contractions). Use these terms and forms of address unless the user writes differently:Language Visit Technician Address the reader as Dutch bezoek technicus je German Einsatz Techniker Sie French intervention technicien vous
Full instructions
Read and follow: $SHARED/SKILL.md, with the Step 0 overrides above.