Logo van Resource Lifecycle

Resource Lifecycle

Community
adamentwistle
resource-lifecycle

Every acquired resource — connection, file, lock, transaction, subprocess, timer, listener, stream, temp file, cursor — has an owner and a release on every exit path, including errors and cancellation. Use when writing or reviewing code that opens, connects, spawns, subscribes, schedules, locks, begins a transaction, or creates anything with a close/dispose/unsubscribe counterpart, and for bugs described as "slow after a while", "too many open files", "pool exhausted", or "process won't exit".

Overzicht

Uitgeveradamentwistle
Repositoryfable-skills
Skillnaamresource-lifecycle
Sterren
98
Forks
11
Meegeleverde bestanden
Alleen instructies
LicentieMIT
Links
  • Instructies in Markdown

    Een SKILL.md-bestand dat het model laadt wanneer nodig, zodat het alleen tokens kost als een verzoek er daadwerkelijk bij past.

  • Werkt met elk LLM

    AI-skills zijn gewone Markdown, geen aanbiederspecifieke code. Daardoor werken ze met GPT, Claude, Gemini, Grok of een lokaal model.

  • Compleet zonder extra bestanden

    Alles wat het model nodig heeft, staat in de instructies — geen extra bestanden om te synchroniseren.

  • Open source

    Gepubliceerd door adamentwistle op GitHub. Lees de broninhoud voordat je de skill installeert.

Installatie

Installeer de AI-skill Resource Lifecycle in TypingMind om deze met elke LLM te gebruiken, of voeg de skill toe aan een andere agent die SKILL.md kan lezen.

1

Installeren in TypingMind

TypingMind installeert een skill rechtstreeks vanuit de GitHub-map — het leest SKILL.md, bundelt de bijbehorende bestanden en slaat het resultaat lokaal op.

  1. Open de app en ga naar Plug-ins → Skills.
  2. Kies "Installeren via GitHub".
  3. Plak de onderstaande URL van de skillmap en bevestig.
    https://github.com/adamentwistle/fable-skills/tree/main/resource-lifecycle
  4. Schakel de skill in elke chat in waarin je deze beschikbaar wilt hebben.
Plug-ins → Skills → Nieuwe skill → Via GitHub-URL. Plak vervolgens de map-URL en druk op Doorgaan.
2

Installeren in een andere agent

Elke agent die het Agent Skills-formaat kan lezen, kan deze skill gebruiken — kopieer de map naar de skillmap van die agent.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/adamentwistle/fable-skills.git /tmp/fable-skills
mkdir -p .claude/skills
cp -r /tmp/fable-skills/resource-lifecycle .claude/skills/resource-lifecycle
Start Claude Code na het kopiëren opnieuw op, zodat de nieuwe skill wordt herkend.

Gebruik deze skill in TypingMind

Schakel Resource Lifecycle in een willekeurige chat in TypingMind in en het model doet de rest. De naam en beschrijving staan in de systeemprompt. Zodra een verzoek erbij past, laadt het model zelf de volledige instructies — je hoeft de skill nooit handmatig aan te roepen en deze kost pas tokens wanneer je de skill daadwerkelijk gebruikt.

Het model laadt Resource Lifecycle automatisch zodra een verzoek erbij past.

Werkt met elk AI-model

AI-skills zijn gewone Markdown-instructies in plaats van aanbiederspecifieke code. Daardoor is Resource Lifecycle niet gebonden aan het model waarvoor de skill is geschreven. Installeer de skill één keer in TypingMind en gebruik deze met GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama of een lokaal model dat je zelf draait — allemaal met je eigen API-sleutels.

  • Alleen geladen wanneer nodig

    De systeemprompt bevat alleen de naam en beschrijving. De instructies worden bij het eerste bijpassende verzoek opgehaald, dus een ongebruikte skill kost niets.

  • Wissel van model tijdens een chat

    Omdat de skill uit instructies bestaat en niet uit code, blijft deze werken als je van model wisselt — het volgende model leest hetzelfde SKILL.md-bestand.

Skillinstructies

Dit is de inhoud van SKILL.md die het model laadt. Lees deze vóór de installatie — een skill bestaat uit instructies die je model zal volgen.

resource-lifecycle

Weak resource handling opens, uses, and closes on the happy path; the first exception leaks the handle, and the leak surfaces a week later as "pool exhausted" or a process that never exits. Strong handling decides who owns each resource at the moment it is acquired and writes the release before the use.

1. Inventory the acquisitions

Before finishing a diff, grep it for every acquire: open(, connect, spawn / exec / Popen, begin / transaction, lock / acquire, setInterval / setTimeout / schedule, addEventListener / .on( / subscribe, createReadStream / pipe, mkstemp / tmp, cursor, Session(, new Client(. One line per hit: resource → owner → release site. A hit with no release site is a leak until proven otherwise.

2. Use the scoped construct the language gives you

  • Python with, JS/TS try/finally (or using / await using where supported), Go defer on the line after the acquire, Java try-with-resources, Rust drop. The release lives in the construct, not at the bottom of the function.
  • Check the release runs on every exit: early return, continue, thrown error, and in async code, cancellation and abort (see concurrency-reasoning). An AbortSignal, CancelledError, or context cancellation must still reach the release.
  • Release in reverse acquisition order. A release that can itself throw is wrapped so the remaining releases still run.

3. Ownership across boundaries

  • A function that returns an open resource (stream, connection, cursor) hands ownership to the caller. Say so in its name or docstring (open_…, acquire_…) and check every caller closes it. Prefer returning the result and closing inside.
  • A resource held in a field or module global needs a shutdown hook. Find where the project shuts down (signal handler, app.on('close'), atexit, lifespan) and register the release there.
  • Callbacks registered in a lifecycle (React effect, component mount, plugin activate) are unregistered in the matching teardown. Every on has an off; every setInterval has a clearInterval.

4. Pools, transactions, subprocesses, temp files

  • Pools: acquire with a timeout; return in finally; never hold a connection across an await on something unrelated (an external HTTP call). Pool size comes from config, not a literal.
  • Transactions: commit on success, roll back on any exception, and never hold one open across a user or network wait. A "transaction" opened inside another is a savepoint or a bug; check which the library does.
  • Subprocesses: read or redirect both stdout and stderr (an unread pipe fills and deadlocks the child); set a timeout; on timeout kill and then wait so no zombie remains; close the pipes.
  • Temp files and directories: create through the platform API, remove in finally, and never present one as the result.

5. Bound what accumulates

Caches, listener lists, in-memory queues, and pending-promise maps grow forever unless something removes entries. Name the eviction: TTL, max size, or removal on completion. An unbounded Map keyed by request ID is a leak with extra steps (see perf-sanity).

6. Prove it

Exercise the error path once: force an exception after the acquire (bad input, a mocked failure) and observe that the release ran — pool count back to baseline, open-handle count flat, the process exits without process.exit(), the temp dir empty. Then run the operation 100 times in a loop and watch the count. A leak invisible once is obvious at 100.

Reporting

Paste the step-1 inventory with each release site, and the step-6 observation. "Closes the connection" without an observed run is a claim, not a result.

Veelgestelde vragen

Wat doet de AI-skill Resource Lifecycle?

Every acquired resource — connection, file, lock, transaction, subprocess, timer, listener, stream, temp file, cursor — has an owner and a release on every exit path, including errors and cancellation. Use when writing or reviewing code that opens, connects, spawns, subscribes, schedules, locks, begins a transaction, or creates anything with a close/dispose/unsubscribe counterpart, and for bugs described as "slow after a while", "too many open files", "pool exhausted", or "process won't exit".

Waarom Resource Lifecycle gebruiken in TypingMind?

Omdat je deze skill één keer installeert en met elk model kunt gebruiken. Resource Lifecycle bestaat uit gewone Markdown in plaats van aanbiederspecifieke code. Dezelfde skill werkt dus met GPT-5, Claude, Gemini, Grok of een lokaal model, en je kunt midden in een chat van model wisselen zonder dat de skill niet meer werkt. TypingMind werkt met je eigen API-sleutels, dus je betaalt aanbieders rechtstreeks in plaats van een abonnement per gebruikersplek. Je skills en chats blijven in je eigen opslag.

Hoe installeer ik Resource Lifecycle in TypingMind?

Open Plug-ins → Skills → Installeren vanaf GitHub in TypingMind en plak https://github.com/adamentwistle/fable-skills/tree/main/resource-lifecycle. TypingMind leest het bestand SKILL.md en installeert het als een skill die je per chat kunt inschakelen.

Welke AI-modellen kunnen Resource Lifecycle gebruiken?

Elk model dat je in TypingMind koppelt. AI-skills bestaan uit gewone Markdown-instructies in plaats van aanbiederspecifieke code. GPT, Claude, Gemini, Grok en lokale modellen kunnen deze skill dus allemaal laden wanneer een verzoek erbij past.

Hoeveel AI-modellen kan ik met Resource Lifecycle gebruiken?

Zoveel als je wilt. Zolang een model skills ondersteunt, kun je Resource Lifecycle ermee gebruiken: GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama en meer. Allemaal in TypingMind met je eigen API-sleutels.

Is de AI-skill Resource Lifecycle gratis?

Ja. Deze skill is door adamentwistle op GitHub gepubliceerd onder de licentie MIT. Je betaalt alleen je eigen AI-aanbieder voor de tokens die je gebruikt.

Wat zijn AI-skills?

Een AI-skill is een herbruikbare bundel instructies die een AI-model leert hoe het één specifieke taak moet uitvoeren. Deze volgt het open Agent Skills-formaat: een bestand met de naam SKILL.md met een naam en beschrijving, plus eventuele scripts, sjablonen of referentiebestanden die het model nodig heeft. Het model leest de instructies alleen als je verzoek bij de skill past. Een geïnstalleerde skill kost dus niets zolang deze niet wordt gebruikt.

Waarin verschillen AI-skills van plug-ins of MCP-servers?

Een plug-in of MCP-server geeft een model nieuwe tools om aan te roepen: code die ergens wordt uitgevoerd en een resultaat teruggeeft. Een AI-skill geeft het model juist kennis en een werkwijze: hoe het een taak moet aanpakken, welke stappen het moet volgen en hoe goede uitvoer eruitziet. Skills bestaan uit gewone Markdown en hebben dus geen server, API-sleutel of runtime nodig. Ze werken met elk model.

Toon alles

Maak nu je eigen AI-werkruimte

Schrijf je in voor onze nieuwsbrief en blijf op de hoogte van nieuwe functies en toekomstige weggeefacties 👇