llm-model-lifecycle
Skill4 starsChanged 3 months agoApache-2.0View on GitHub
Deterministically snapshot, unload, verify, and restore models on a local llama.cpp llama-server router or Ollama server during resource-safe ComfyUI generation without asking the LLM to invent lifecycle scripts.
In this repository139 other files it gives its agents.
- 3d-animation-short-generatorSkill
- ace-step-xlSkill
- adapt-screenplaySkill
- asset-approvalSkill
- audience-simSkill
- audio-masterSkill
- batch-recoverySkill
- beat-sheetSkill
- book-planSkill
- brand-promo-video-generatorSkill
- campaign-brandSkill
- campaign-deliverySkill
- character-bibleSkill
- character-simSkill
- comfyui-api-v2Skill
- comfyui-assetsSkill
- comfyui-binding-auditSkill
- comfyui-cliSkill
- comfyui-discoverSkill
- comfyui-handoffSkill
- comfyui-mcpSkill
- comfyui-offline-batchSkill
- comfyui-runSkill
- comfyuiSkill
- comfyui-troubleshootSkill
- comfyui-workflowSkill
- content-repurposeSkill
- context-shardsSkill
- continuity-checkSkill
- co-op-game-intro-generatorSkill
- creative-pressure-testSkill
- creative-production-specSkill
- crew-reviewSkill
- decision-tree-interviewSkill
- delivery-qcSkill
- design-systemSkill
- dialogue-audio-authoritySkill
- dialogue-timing-preflightSkill
- dialogue-voiceSkill
- director-bookSkill
- documented-creative-discoverySkill
- edit-assistSkill
- editorial-packageSkill
- editorial-reconciliationSkill
- editor-project-exportSkill
- edit-planSkill
- evidence-researchSkill
- ffmpegSkill
- film-completenessSkill
- film-masterSkill
- generation-budgetSkill
- generation-model-setupSkill
- generation-packSkill
- generation-workflow-setupSkill
- guided-production-wizardSkill
- h3-prompt-writingSkill
- handdrawn-live-video-generatorSkill
- imagemagickSkill
- kdenlive-exportSkill
- krea-2Skill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
9 rules. About 0 are common, 5 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 11
Use this skill when Story-Film must release local LLM memory for ComfyUI and later restore the model state that existed before the handoff.
- Distinctive: line 19
Use the endpoint already reported by Pi, the project resource policy, or a trusted runtime source.
- Very specific: line 21
Use scripts/llm_model_lifecycle.py.
- Very specific: line 22
Prefer the auto adapter when the endpoint may be either a llama.cpp router or Ollama.
- Very specific: line 23
Before unloading, snapshot the exact set of resident models to 00_project/llm_model_snapshot.json.
- Distinctive: line 26
Verify the restored model set before returning control to normal Story-Film work.
- Distinctive: line 27
Do not kill or restart the whole model server merely to free model memory when its native model lifecycle API is available.
- Very specific: line 28
Keep the legacy command resource-handoff adapter only for installations whose server does not expose a supported native model lifecycle API.
- Distinctive: line 32
Use the router model API:
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
LLM Model Lifecycle
Use this skill when Story-Film must release local LLM memory for ComfyUI and later restore the model state that existed before the handoff.
Read
Read ../../references/RESOURCE_SAFE_GENERATION.md.
Required behavior
- Use the endpoint already reported by Pi, the project resource policy, or a trusted runtime source.
- Prove that the endpoint is local with
scripts/llm_runtime.pyor the lifecycle helper's local-only guard. - Use
scripts/llm_model_lifecycle.py. Never author an ad hoc curl, jq, shell loop, or one-off Python lifecycle script. - Prefer the
autoadapter when the endpoint may be either a llama.cpp router or Ollama. Explicitllama-serverandollamaadapters are also supported. - Before unloading, snapshot the exact set of resident models to
00_project/llm_model_snapshot.json. - Unload through the server's native model API and verify that the models are actually absent from memory.
- During restore, remove untracked temporary models that appeared while ComfyUI was running, then restore the original snapshot exactly.
- Verify the restored model set before returning control to normal Story-Film work.
- Do not kill or restart the whole model server merely to free model memory when its native model lifecycle API is available.
- Keep the legacy
commandresource-handoff adapter only for installations whose server does not expose a supported native model lifecycle API.
llama.cpp router mode
Use the router model API:
GET /models
POST /models/unload {"model": "<id>"}
POST /models/load {"model": "<id>"}Poll the model list and status after every load or unload. Do not assume that a successful HTTP response means memory has already reached the requested state.
Ollama
Use:
GET /api/ps
POST /api/generateFor unload, send an empty generation request with keep_alive set to 0. For restore, send an empty generation request with the configured restore keep-alive value. Verify both operations through /api/ps.
Commands
Inspect the currently resident model set:
python scripts/llm_model_lifecycle.py list --runtime auto --endpoint <local-endpoint>Snapshot and unload:
python scripts/llm_model_lifecycle.py snapshot-unload --runtime auto --endpoint <local-endpoint> --state 00_project/llm_model_snapshot.jsonRestore the snapshot:
python scripts/llm_model_lifecycle.py restore --state 00_project/llm_model_snapshot.jsonThe resource-safe handoff calls these operations directly. The agent must not replace them with generated scripts.
Done
Done when the original local model set is restored and verified, or when a deterministic lifecycle error is recorded for the next model turn.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

