add-a-lib

A scaffold for adding a shared TypeScript library to the `libs/` folder of a monorepo, a repository that holds multiple apps or services. It sets up the package files and a single public entry point for code used in at least two places.

In plain words
What is it for?
Use it when extracting shared code into a package such as `@stack/ui`, `@stack/db`, or `@stack/auth`. It creates the package configuration, TypeScript settings, public entry file, and consumer wiring.
Why use it?
It prevents the same helper, type, component, or client from being copied into several apps. The shared library becomes one source of truth that other packages can import.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/lonormaly/builders-stack/add-a-lib
Any agent
npx skills add lonormaly/builders-stack --skill add-a-lib
Clone the repo
git clone --depth 1 https://github.com/lonormaly/builders-stack

Made for: Claude Code, Codex.

Per session 81 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 717 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00081 $0.00717
Opus 5 $0.00041 $0.00358
Sonnet 5 $0.00016 $0.00143
Haiku 4.5 $0.00008 $0.00072

Measured 2d ago against content hash 154f9cd760d7, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

add-a-lib scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

agents/skills/add-a-lib/SKILL.md · 73 lines

How it starts

The opening of the file, as written. The whole thing — 73 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Add a lib

A libs/* package is shared code that is never served — other packages consume it, it consumes nobody upward. Reach for this when the same helper/type/component is about to exist in two places.

When to use

  • A util, type, component, or client is needed by 2+ apps/services → extract it into a lib.
  • Not when it's used in exactly one place — leave it there (YAGNI). A lib for one consumer is premature.

Steps

  1. Pick the name. libs/<name>, package @stack/<name>. Keep it a role, not a feature (ui, db, auth, ai, analytics).

  2. Create the folder + files:

    libs/<name>/
    ├── package.json
    ├── tsconfig.json
    └── src/
        └── index.ts        # the ONE public door
    
  3. package.json — name it @stack/<name>, point exports at the barrel:

    {
      "name": "@stack/<name>",
      "private": true,
      "type": "module",
      "exports": { ".": "./src/index.ts" },
      "scripts": { "typecheck": "bash ../../scripts/typecheck-native.sh --noEmit" }
    }
    
  4. tsconfig.json — extend the root base, never fork options:

    { "extends": "../../tsconfig.base.json", "include": ["src"] }
    
  5. src/index.ts — this is the only thing consumers may import. Re-export the public surface; keep everything else internal:

    export { thing } from "./thing";
    export type { ThingOptions } from "./thing";
    
  6. Install so the workspace links it: bun install (root). The @stack/<name> name now resolves across the workspace.

    bun run check:typescript enforces the shared stable TypeScript 7 checker for every workspace.

  7. Consume it from an app/service by package name only:

    import { thing } from "@stack/<name>"; // ✅
    import { thing } from "@stack/<name>/src/internal/thing"; // ❌ deep import — forbidden
    

Rules to respect

  • No upward import: the lib must not import from apps/ or services/. If it needs to, the boundary is wrong — the caller should pass the dependency in.
  • One public door: anything not exported from src/index.ts is private. Don't let consumers reach into internals.
  • No Tiltfile change — libs aren't served, so they get no Tilt resource.

Read the full file on GitHub · 73 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 73 lines · 81 tokens per session scan A 154f9cd760d7

Subscribe to this mod's changes

add-a-lib is a skill published in the GitHub repository lonormaly/builders-stack (41 stars, last pushed 16d ago), licensed MIT. It adds 81 tokens to every session and 717 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

openspec-archive-change

Archive a completed change in the experimental workflow. Use when the user wants to finalize and archive a change after implementation is complete.

AmanVarshney01/create-better-t-stack · 31 tokens

mastra

Comprehensive Mastra framework guide. Teaches how to find current documentation, verify API signatures, and build agents and workflows. Covers documentation lookup strategies (embedded docs, remote docs), core concepts (agents vs workflows, tools, memory, RAG), TypeScript requirements, and common patterns. Use this…

vobase/vobase · 83 tokens

Beads Workflow Optimizer

Optimizes Beads workflow activation, parallel processing, and task management. Use when working with Beads issues, managing dependencies, or optimizing development workflows in projects with complex task dependencies.

aegntic/cldcde · 42 tokens

nen-contract-mantle

Hold a task's objective, boundaries, protected state, assumptions, and acceptance tests through long or context-shifting work. Use when the user invokes Ten, Ken, 纏, or 堅; work spans several phases, agents, or context windows; requirements may drift; or completion needs a final contract check.

cambridgetcg/agenttool · 70 tokens

openspec-explore

Enter explore mode - a thinking partner for exploring ideas, investigating problems, and clarifying requirements. Use when the user wants to think through something before or during a change.

AmanVarshney01/create-better-t-stack · 39 tokens

openspec-propose

Propose a new change with all artifacts generated in one step. Use when the user wants to quickly describe what they want to build and get a complete proposal with design, specs, and tasks ready for implementation.

AmanVarshney01/create-better-t-stack · 47 tokens