subtree-publish

Publishes monorepo subdirectories to standalone GitHub repositories using git subtree.

636|91|Updated Jan 7, 2026
One-click install
npx skills add https://github.com/cat-xierluo/legal-skills --skill subtree-publish
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: subtree-publish
Source: https://github.com/cat-xierluo/legal-skills/tree/main/skills/subtree-publish
Command: npx skills add https://github.com/cat-xierluo/legal-skills --skill subtree-publish

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

Maintaining skills in a monorepo while distributing them as standalone GitHub repositories requires repetitive manual git subtree commands, remote setup, and release packaging. This Skill automates that entire publishing workflow so each subdirectory stays in one place but ships as an independent repository with versioned Releases.

Core Features & Use Cases

  • Automatic change detection: The --auto mode inspects the latest commit and pushes only the registered subprojects that were modified.
  • First-time registration flow: Guided steps to verify README.md, create the GitHub repository via gh, add the remote, push, register in config/subtree-skills.json, and create the first Release.
  • Automated Release creation: Reads the version from SKILL.md, extracts notes from CHANGELOG.md, and attaches a zip package that excludes runtime artifacts like archive/, __pycache__/, .env files, and local configs.
  • Use Case: After committing updates to a skill in your monorepo, run the auto mode to push the changed subdirectory to its standalone repo and publish a versioned Release with a ready-to-install zip.

Quick Start

After committing changes to a registered skill subdirectory, ask the AI to sync the subtree to the standalone repository and create a Release if the version changed.

Frequently Asked Questions about subtree-publish

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I push a monorepo subdirectory to a separate GitHub repository?

Use git subtree push with the subdirectory prefix and a remote pointing to the target repository. This Skill wraps that flow in scripts/subtree-push.sh, which handles remote creation via gh, repo naming, and pushing in one command.

How to automatically detect which monorepo subprojects changed and publish them?

Run scripts/subtree-push.sh with the --auto flag after committing. It diffs the latest commit against the registered skills in config/subtree-skills.json and pushes only the subdirectories whose files were modified.

What dependencies are required to use git subtree publishing scripts?

You need git with subtree support (preinstalled on macOS), the GitHub CLI (gh) for repository and Release creation, and jq for parsing the JSON configuration file. Install gh and jq via Homebrew.

Does git subtree push work with files ignored by .gitignore?

No, git subtree only pushes committed files, so anything excluded by the monorepo root .gitignore never reaches the standalone repository. The release packaging script additionally excludes runtime artifacts like archive/, output/, __pycache__/, and .env files from the zip.

When should I not use git subtree for publishing subdirectories?

Do not use it for initially creating a monorepo or managing git submodules, which are different mechanisms. Also avoid editing files directly in the standalone repository, since all changes must originate in the monorepo to keep histories consistent.