@refine with mingle: true
Reusable teaching specifications become part of the concrete tutor. They are structurally woven, not appended.
Hands-on tutorial
This is a copyable WeaveMark specification, not a concept
essay. You will write one tutor spec, use @refine to weave in
reusable teaching behavior, compose it, and then adapt it for a
different lesson.
@refine, @ask, branches, and output contracts.
Source and folder links open GitHub. Commands assume the repository-root setup from Tutorial 1.
Work from the repository root. Create a scratch folder so the tutorial is safe to edit and rerun.
cd weavemark
mkdir -p outputs/tutorial-tutor
Save this file as
outputs/tutorial-tutor/adaptive-tutor.weavemark.md. It is
already a real WeaveMark program: refinements,
variables, branching, an
output contract, and assertions.
<!-- Save as outputs/tutorial-tutor/adaptive-tutor.weavemark.md -->
@promplet version: 0.7
@refine module:weavemark.std.teaching.socratic_tutoring mingle: true
@refine module:weavemark.std.teaching.misconception_diagnosis mingle: true
# Adaptive learning tutor
@style "Warm, precise, and Socratic. Ask before explaining. Never shame the learner."
Teach @{topic} to @{learner_context}.
Learning target: @{learning_goal}
Start by asking one diagnostic question. Use the learner's
answer to choose the explanation depth.
@match learner_level
"beginner" ==>
Use a concrete analogy before formal terms.
"intermediate" ==>
Connect intuition to the formal rule.
"advanced" ==>
Use counterexamples and transfer tasks.
@if include_practice
Add three practice tasks: one easy, one transfer,
and one challenge.
@output enforce: strict
Return exactly these sections:
1. Diagnostic question
2. Explanation
3. Likely misconception
4. Practice
5. Review plan
@assert contains: "Likely misconception"
@assert contains: "Diagnostic question"
The complete, tested specs for this tutorial are checked in under
promplets/tutorials/:
adaptive-tutor.weavemark.md
and, with the @ask variant,
adaptive-tutor-guided.weavemark.md.
Now provide values and compile the concrete tutor prompt. The output should read as one coherent teaching prompt, not a pile of imported fragments.
weavemark outputs/tutorial-tutor/adaptive-tutor.weavemark.md \
--batch-only \
--var topic="Bayes' rule" \
--var learner_context="a product manager who knows basic percentages" \
--var learning_goal="use Bayes' rule to update a belief after new evidence" \
--var learner_level=beginner \
--var include_practice=true \
--output outputs/tutorial-tutor/bayes-tutor.md
Open outputs/tutorial-tutor/bayes-tutor.md. Check for the
five required sections and confirm that the final prompt tells the
assistant to diagnose misconceptions before teaching.
bayes-tutor.md is a pastable tutor prompt. Copy it into
ChatGPT, Claude, Gemini, Copilot Chat, or another assistant, then let
the assistant run the tutoring session with you or a learner.
@refine with mingle: trueReusable teaching specifications become part of the concrete tutor. They are structurally woven, not appended.
@match learner_levelOne source handles beginner, intermediate, and advanced learners. No duplicate prompt files.
@if include_practiceOptional practice appears only when the caller requests it. The branch remains readable in Markdown.
@output + @assertThe spec states what the final tutor must include, so the output contract is visible before compilation.
@ask
If a tutor needs a human clarification before compilation, wrap the
rest of the spec in @ask. Notice the shape: the
body of @ask is the specification to continue
compiling after the answer arrives.
@ask matters: some decisions are
too structural for a variable. @ask lets WeaveMark stop,
ask the human, and then compile the following body with that answer
woven into the result.
<!-- Save as outputs/tutorial-tutor/adaptive-tutor-guided.weavemark.md -->
@promplet version: 0.7
@ask clarifying question detail_level: 35%
@refine module:weavemark.std.teaching.socratic_tutoring mingle: true
@refine module:weavemark.std.teaching.misconception_diagnosis mingle: true
# Guided adaptive learning tutor
@style "Warm, precise, and Socratic. Prefer short learner turns over long lectures."
Teach @{topic} to @{learner_context}.
Clarify what the learner should be able to do by the end.
Use the clarification answer as the concrete learning outcome.
@match learner_level
"beginner" ==>
Use a familiar analogy, then name the formal idea.
"intermediate" ==>
Ask the learner to predict the next step before explaining it.
"advanced" ==>
Use a counterexample, then ask for a transfer explanation.
@if include_practice
Add a practice ladder:
- recognition task
- guided application task
- transfer task
- self-explanation prompt
@output enforce: strict
Return exactly these sections:
1. Diagnostic question
2. Learner model
3. Socratic explanation
4. Misconception repair
5. Practice ladder
6. Review plan
@assert contains: "Diagnostic question"
@assert contains: "Misconception repair"
Run it without --batch-only so WeaveMark can ask the
clarification in the terminal:
weavemark outputs/tutorial-tutor/adaptive-tutor-guided.weavemark.md \
--var topic="gradient descent" \
--var learner_context="a designer learning machine-learning basics" \
--var learner_level=beginner \
--var include_practice=true \
--output outputs/tutorial-tutor/gradient-descent-tutor.md
@ask when a
processing-time decision affects the whole structure. Use ordinary
variables when the caller already knows the values.
gradient-descent-tutor.md is also a pastable tutor
prompt. The difference is that WeaveMark first asks you for missing
teaching context, then compiles a more specific prompt for the
assistant.
Do not copy the prompt. Reuse the same specification and change the variables. This is where WeaveMark starts paying rent.
weavemark outputs/tutorial-tutor/adaptive-tutor.weavemark.md \
--batch-only \
--var topic="Python async task cancellation" \
--var learner_context="a Python programmer building their first concurrent CLI" \
--var learning_goal="predict when cancellation propagates and clean up tasks safely" \
--var learner_level=intermediate \
--var include_practice=true \
--output outputs/tutorial-tutor/async-cancellation-tutor.md
Compare the two outputs. The source stays stable, while the compiled prompt changes lesson domain, learner context, and branch behavior.
async-cancellation-tutor.md is a second pastable tutor
prompt. Use it in a chat assistant when you want an async
cancellation lesson instead of a Bayes-rule lesson.
The compiled tutor files are prompts for a teaching conversation. They do not teach the lesson on their own until an assistant runs the prompt.
bayes-tutor.md,
gradient-descent-tutor.md, or
async-cancellation-tutor.md into ChatGPT, Claude, Gemini,
Copilot Chat, or another LLM assistant. The assistant uses that prompt
to run the adaptive tutoring session with the learner.
@refine when reusable behavior should shape the current spec.mingle: true when the refined material should become one prompt, not an appendix.@match and @if for readable variation.@output and @assert to make output obligations explicit.