Skill: Shareable Packages Template (Python & TypeScript)
Portable workflow for making a codebase installable and publishable. Detect the project language first, then follow the matching section.
1. Detect project type
- Python: presence of
pyproject.toml,setup.py,setup.cfg, orrequirements*.txtat repo root. - TypeScript/JavaScript: presence of
package.jsonat repo root (and optionallytsconfig.json).
If both exist, ask the user which package(s) they want to make shareable, or apply the relevant section per directory (e.g. a monorepo with packages/python and packages/ts).
2. Python: Shareable package checklist
2.1 Build and metadata
- A1 Ensure build is declared in
pyproject.toml(PEP 517/518):[build-system]withbuild-backend = "setuptools.build_meta"(orhatchling,flit).[project]withname,version,description,readme,requires-python,dependencies.
- A2 If the project still uses only
setup.py, move metadata andinstall_requiresintopyproject.toml; keep a minimalsetup.pyonly if needed for editable installs. - A3 Set
packages(or[tool.setuptools.packages.find]) so all installable packages are included; excludetest*,docs*, etc.
2.2 Installability
- B1 Imports must be package-relative (e.g.
from mypackage.module import foo). No reliance on repo root insys.pathfor production code. - B2 Optional: use
src/layout (src/<package_name>/) for a cleaner install. - B3 Verify: in a new venv, run
pip install -e .then run the project's test command (e.g.pytest tests/ -q). NoPYTHONPATHhacks.
2.3 Version and artifacts
- C1 Single source of truth for version:
versioninpyproject.tomlor aversion.pyread by it. - C2 Build artifacts:
pip install build && python -m build→dist/*.whlanddist/*.tar.gz.
2.4 Publish (document only; do not run without explicit ask)
- D1 Document: PyPI (public) or private index (CodeArtifact, Nexus, etc.). Consumer install:
pip install <package-name>orpip install --index-url ... <package-name>.
2.5 Scripts (agent may add)
scripts/ensure_shareable.sh: create temp venv,pip install -e ., run tests (e.g.pytest tests/ -q); exit 0 only if all pass.scripts/build.sh: installbuild, runpython -m build, listdist/. No upload.
3. TypeScript/JavaScript: Shareable package checklist
3.1 Build and metadata
- A1 Ensure
package.jsonhas:name,version,description,main(and/ormodule,types),files(e.g.["dist", "src"]),scripts.build. - A2 For TypeScript:
tsconfig.jsonwith correctoutDir(e.g.dist/); build produces output thatmain/module/typespoint to. - A3 Prefer publishable package name (e.g. scoped
@org/package-namefor private npm or org-scoped publish).
3.2 Installability
- B1 Entry points:
main(CJS),module(ESM),types(TypeScript) must resolve to built files (e.g.dist/index.js,dist/index.d.ts). - B2 No reliance on repo root for resolution in published code; use package-relative imports; bundling or path aliases must work from
node_modules. - B3 Verify: in a new directory, run
npm pack(orpnpm pack), thennpm install ./<package>-*.tgzin another folder andrequire()orimportthe package; run the library's tests if present.
3.3 Version and artifacts
- C1 Single source of truth for version:
versioninpackage.json(or tool that writes it, e.g. from git tag). - C2 Build artifacts:
npm run build(orpnpm build); thennpm pack→<name>-<version>.tgz. Optionally prepare fornpm publish --dry-run.
3.4 Publish (document only; do not run without explicit ask)
- D1 Document: npm (public or scoped) or private registry (npm Enterprise, Verdaccio, GitHub Packages, etc.). Consumer:
npm install <package-name>ornpm install --registry=... <package-name>.
3.5 Scripts (agent may add)
scripts/ensure_shareable.sh: in temp dir,npm packfrom project, install the tarball elsewhere, run consumer smoke test or the project's test script.scripts/build.sh:npm run build(orpnpm build), thennpm pack; list the generated.tgz. No publish.
4. Shared rules (Python and TypeScript)
- Do not publish to a real registry (PyPI, npm, etc.) unless the user explicitly asks.
- Do not bump version or create git tags unless the user asks.
- Do not split the repo into multiple packages unless the user asks.
- After edits, run the project's test command and fix any failures before reporting success.
5. Quick reference
| Goal | Python | TypeScript |
|---|---|---|
| Build config | pyproject.toml [build-system] + [project] | package.json name, version, main/module/types, files |
| Install local | pip install -e . | npm link or npm install /path/to/tarball.tgz |
| Build artifacts | python -m build → dist/ | npm run build then npm pack → .tgz |
| Verify shareable | New venv, pip install -e ., run tests | New dir, install from npm pack, run tests |
| Publish | Document only; use twine/CI when asked | Document only; use npm publish when asked |
6. Optional: Project-specific plan doc
For larger repos, the agent can create or update a plan document (e.g. docs/shareable_packages_plan.md) that:
- Repeats the relevant checklist (Python and/or TS) for this repo.
- Adds project-specific paths (e.g. test command, package name).
- References this skill so future agents follow the same workflow.
Use the same checklist order (A → B → C → D) and "do not publish/bump/split unless asked" rules.
