Logo vun Resource Lifecycle

Resource Lifecycle

Communautéit
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".

Iwwersiicht

Editeuradamentwistle
Repositoryfable-skills
Skill-Nummresource-lifecycle
Stären
98
Forks
11
Matgeliwwert Fichieren
Nëmmen Instruktiounen
LizenzMIT
Linken
  • Instruktiounen am Markdown-Format

    Eng SKILL.md-Datei, déi de Modell bei Bedarf luet, soudatt nëmmen Token ufalen, wann eng Ufro tatsächlech dozou passt.

  • Funktionéiert mat all LLM

    KI-Skills si reng Markdown, keen ubidderspezifesche Code. Dofir funktionéiert dëse Skill mat GPT, Claude, Gemini, Grok oder engem lokale Modell.

  • Alles an den Instruktiounen

    Alles, wat de Modell brauch, steet an den Instruktiounen — keng zousätzlech Dateien ze synchroniséieren.

  • Open Source

    Vum adamentwistle op GitHub verëffentlecht. Liest de Quelltext, ier Dir de Skill installéiert.

Installatioun

Installéiert de KI-Skill Resource Lifecycle an TypingMind, fir e mat all LLM ze benotzen, oder füügt en an en anere KI-Agent an, deen SKILL.md liest.

1

An TypingMind installéieren

TypingMind installéiert e Skill direkt aus sengem GitHub-Dossier — dobäi gëtt SKILL.md gelies, d'Ressourcedateie gi gebëndelt an d'Resultat gëtt lokal gespäichert.

  1. Maacht d'App op a gitt op Plugins → Skills.
  2. Wielt „Vun GitHub installéieren“.
  3. Pecht d'URL vum Skill-Dossier hei drënner an a bestätegt.
    https://github.com/adamentwistle/fable-skills/tree/main/resource-lifecycle
  4. Aktivéiert de Skill an all Chat, an deem Dir e benotze wëllt.
Plugins → Skills → Skill afügen → Vu GitHub-URL, pecht dann d'URL vum Dossier an a klickt op Weider.
2

An engem anere KI-Agent installéieren

All KI-Agent, deen d'Format Agent Skills liest, kann dëse Skill benotzen — kopéiert den Dossier an de Skill-Verzeechnes vun deem KI-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 nom Kopéieren nei, fir datt den neie Skill erkannt gëtt.

An TypingMind benotzen

Aktivéiert Resource Lifecycle an engem Chat vun TypingMind, an de Modell iwwerhëlt de Rescht. Den Numm an d'Beschreiwung stinn am System-Prompt. Soubal eng Ufro dozou passt, luet de Modell déi komplett Instruktioune selwer — Dir musst de Skill ni manuell opruffen, an et fale keng Token un, bis en tatsächlech benotzt gëtt.

De Modell luet Resource Lifecycle automatesch, soubal eng Ufro dozou passt.

Funktionéiert mat all KI-Modell

KI-Skills si reng Markdown-Instruktiounen amplaz vun ubidderspezifeschem Code. Dofir ass Resource Lifecycle net un de Modell gebonnen, fir deen de Skill geschriwwe gouf. Installéiert en eemol an TypingMind a benotzt e mat GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama oder engem lokale Modell, deen Dir selwer bedreift — alles mat Ären eegenen API-Keys.

  • Gëtt nëmme gelueden, wann et néideg ass

    De System-Prompt enthält nëmmen den Numm an d'Beschreiwung. D'Instruktioune gi bei der éischter passender Ufro gelueden, soudatt en onbenotzte Skill näischt kascht.

  • De Modell am lafende Chat wiesselen

    Well de Skill aus Instruktiounen amplaz vu Code besteet, funktionéiert en och no engem Modellwiessel — den nächste Modell liest déi selwecht SKILL.md-Datei.

Skill-Instruktiounen

Dëst ass den Inhalt vu SKILL.md, deen de Modell luet. Liest e virun der Installatioun — e Skill besteet aus Instruktiounen, déi Äre Modell befollegt.

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.

Heefeg gestallte Froen

Wat mécht de KI-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".

Firwat Resource Lifecycle op TypingMind benotzen?

Well Dir en eemol installéiert a mat all Modell benotze kënnt. Resource Lifecycle besteet aus einfachem Markdown amplaz vun ubidderspezifeschem Code. Dee selwechte Skill funktionéiert also mat GPT-5, Claude, Gemini, Grok oder engem lokale Modell – an Dir kënnt de Modell matzen am Chat wiesselen, ouni datt de Skill ophält ze funktionéieren. TypingMind benotzt Är eegen API-Schlësselen, sou datt Dir d'Ubidder direkt bezuelt amplaz vun engem Abonnement pro Benotzerplaz. Är Skills a Chats bleiwen an Ärem eegene Späicher.

Wéi installéieren ech Resource Lifecycle an TypingMind?

Maacht an TypingMind Plugins → Skills → Vu GitHub installéieren op a setzt https://github.com/adamentwistle/fable-skills/tree/main/resource-lifecycle an. TypingMind liest d'Datei SKILL.md an installéiert de Skill, deen Dir pro Chat aktivéiere kënnt.

Wéi eng KI-Modeller kënnen Resource Lifecycle benotzen?

All Modell, deen Dir an TypingMind verbënnt. KI-Skills sinn einfach Markdown-Instruktiounen an net ubidderspezifesche Code. Dofir kënne GPT, Claude, Gemini, Grok a lokal Modeller dëse Skill lueden, wann eng Ufro dozou passt.

Wéi vill KI-Modeller kann ech mat Resource Lifecycle benotzen?

Esou vill Dir wëllt. Soulaang e Modell Skills ënnerstëtzt, kënnt Dir Resource Lifecycle domat benotzen – GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama a méi – alles op TypingMind mat Ären eegenen API-Schlësselen.

Ass de KI-Skill Resource Lifecycle gratis?

Jo. De Skill gëtt vum adamentwistle ënner der Lizenz MIT op GitHub publizéiert. Dir bezuelt nëmmen Ären eegene KI-Ubidder fir d'Token, déi Dir benotzt.

Wat si KI-Skills?

E KI-Skill ass e weiderverwendbaart Pak vun Instruktiounen, dat engem KI-Modell bäibréngt, wéi en eng bestëmmt Aufgab erfëllt. E follegt dem oppenen Agent Skills-Format: eng Datei SKILL.md mat engem Numm an enger Beschreiwung, plus all Scripten, Virlagen oder Referenzdateien, déi de Modell eventuell brauch. De Modell liest d'Instruktiounen eréischt, wann Är Ufro zum Skill passt. En installéierte Skill kascht also näischt, bis e benotzt gëtt.

Wéi ënnerscheede sech KI-Skills vu Plugins oder MCP-Serveren?

E Plugin oder MCP-Server gëtt engem Modell nei Tools, déi en opruffe kann – Code, deen iergendwou leeft an e Resultat zeréckgëtt. E KI-Skill gëtt dem Modell dogéint Wëssen an eng Virgoensweis: wéi en eng Aufgab ugeet, wéi eng Schrëtt en nokënnt a wéi eng gutt Ausgab ausgesäit. Skills bestinn aus einfachem Markdown, brauche kee Server, keen API-Schlëssel a keng Lafzäitëmfeld a funktionéiere mat all Modell.

All weisen

Elo Ären eegene KI-Workspace ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇