Documentation
¶
Overview ¶
This sample demonstrates the Skills middleware, which offers the model a local library of specialised instructions stored as SKILL.md files.
The middleware injects a system prompt listing each skill's name and description, and registers a use_skill tool. The model picks the skill that fits and calls use_skill to load its full body into the conversation, so the heavier instructions stay off the hot path until they are wanted.
Four visually distinct skills ship here, so the effect is easy to eyeball: haiku, pirate, shakespeare, and eli5.
Run it:
go run .
Or with the Dev UI, to watch the use_skill call in a trace of every run at http://localhost:4000/traces:
curl -sL cli.genkit.dev | bash # install the Genkit CLI, once genkit start -- go run .
Or over HTTP. The question decides which skill loads:
curl -N -X POST 'http://localhost:8080/askFlow?stream=true' \
-H "Content-Type: application/json" \
-d '{"data": {"question": "Write a haiku about debugging code."}}'
curl -N -X POST 'http://localhost:8080/askFlow?stream=true' \
-H "Content-Type: application/json" \
-d '{"data": {"question": "Explain recursion to me like I am five."}}'