スキル一覧に戻る
shawn-sandy

npm-monorepo-publish

by shawn-sandy

0🍴 0📅 2026年1月18日
GitHubで見るManusで実行

SKILL.md


name: npm-monorepo-publish description: Publish packages to npm using release branch workflow with PR review before publishing version: 2.1.0

npm Monorepo Publishing Skill

Purpose

Guide the publishing of packages to npm using a release branch workflow that ensures:

  • All publishes reviewed via PR before going live
  • Build/test validation before creating release branch
  • Main branch never force-pushed (fix forward only)
  • Full audit trail with every publish linked to a PR

Core principle: Never publish directly from main. Always use release branches.

Scope: Works with any package in the monorepo (currently: @fpkit/acss, expandable to other packages)


When to Invoke

User requests:

  • "Publish to npm"
  • "Release a new version"
  • "Create a patch/minor/major release"
  • "Publish the package"

Arguments:

  • --dry-run - Validate without publishing

First step: If multiple packages exist or context is unclear, ask user which package to publish.


Project Context

FilePurpose
lerna.jsonVersioning mode (independent), conventional commits
packages/{name}/package.jsonPackage name, version, publishConfig, scripts
CHANGELOG.mdRelease history format

Key configuration:

  • Versioning: Independent (Lerna manages per-package)
  • Conventional commits: Enabled (auto-changelog)
  • Requirements: Node >=22.12.0, npm >=8.0.0

Current packages:

  • @fpkit/acss in packages/fpkit/

Workflow Overview

8-Step Release Branch Flow:

StepActionChanges Made
1. ValidatePre-flight checksNone (read-only)
2. ReviewVersion selectionNone (read-only)
3. BuildRun build/lint/testBuild artifacts in libs/
4. BranchCreate release/v{version}New git branch
5. VersionBump package.jsonpackage.json updated
6. DocumentUpdate CHANGELOGCHANGELOG.md updated
7. PR ReviewPush branch, create PRRemote branch, PR created
8. PublishAfter merge, publish to npmnpm publish, git tags

For detailed instructions: See references/detailed-workflow.md


Quick Reference

Experienced users - full command sequence:

# Validate → Branch → Version → PR → Publish

git checkout main && git status
cd packages/fpkit && npm run build && npm run lint && npm test && cd ../..
git checkout -b release/v{VERSION}
lerna version {patch|minor|major} --no-push --no-git-tag-version
# Update CHANGELOG, commit
git push -u origin release/v{VERSION}
gh pr create --title "chore(release): publish @fpkit/acss@{VERSION}" --body "..."
# After PR merge:
git checkout main && git pull
lerna publish from-package --yes --otp={6-digit-code}
git push --follow-tags
git branch -d release/v{VERSION} && git push origin --delete release/v{VERSION}

Common Mistakes to Avoid

❌ Don't✅ Do
Publish directly from mainUse release branches
Skip build/lint/test validationRun all checks before branching
Use git reset on mainFix forward with new commits
Proceed without PR reviewAlways require PR approval
Guess version numberCheck npm registry first
Use expired OTP codesGenerate fresh OTP before publish
Force-push shared branchesPush normally, preserve history
Publish without CHANGELOGUpdate CHANGELOG before PR

Safety Checks

Pre-publish Blockers

Abort if any of these fail:

CheckCommandExpected
Clean working treegit statusNo uncommitted changes
Correct branchgit branch --show-currentmain
Node versionnode --version>= 22.12.0
npm versionnpm --version>= 8.0.0
Buildnpm run buildExit code 0
Lintnpm run lintNo errors (warnings OK)
Testsnpm testAll pass
Version availablenpm view {pkg}@{next-ver}404 error
npm authnpm whoamiValid username

Major Version Protection

If major version detected (X.0.0 → X+1.0.0):

⚠️ BREAKING CHANGE - Major version bump

Requires before proceeding:
- MIGRATION.md guide created
- CHANGELOG lists all breaking changes
- Documentation updated

Confirm: "yes, publish major version"

Wait for exact confirmation phrase. If not confirmed: Abort.


Dry-Run Mode

Flag: --dry-run

ActionBehavior
Steps 1-3✅ Run full validation
Steps 4-8ℹ️ Preview only - no changes made
OutputShows: branch name, version change, files to publish

Use case: Test workflow before real publish, especially from feature branches


Recovery Decision Tree

Was package published to npm?
│
├─ NO → Was PR merged?
│        ├─ NO → Delete branch, fix issues, restart
│        └─ YES → Fix forward on main, new release PR
│
└─ YES → Publish corrective patch via new PR
         (Cannot unpublish from npm)

For detailed recovery scenarios: See references/rollback-recovery.md

Quick recovery guide:

SituationActionRisk
Pre-flight failedFix on main, restartNone
Release branch created, no PRDelete branch, restartNone
PR merged, not publishedFix forward, new PRLow
Published to npmPatch + deprecateMedium

Tool Usage Guide

Use these tools in order of preference:

ToolWhen to UseExample
ReadRead project filespackage.json, lerna.json, CHANGELOG.md
BashGit/npm commandsgit status, npm whoami, lerna publish
AskUserQuestionVersion confirmationMajor version warnings, publish confirmation
TodoWriteTrack workflow stepsMark validation complete, track progress

Never use:

  • Write - Lerna handles file updates automatically
  • Edit - Version bumps managed by Lerna

Parallel execution:

  • ✅ Pre-flight checks (Step 1): Run in parallel
  • ❌ Build/lint/test (Step 3): Run sequentially
  • ✅ Post-publish verification: Run in parallel

Key Files

This skill reads:

  • lerna.json - Lerna configuration
  • packages/fpkit/package.json - Package metadata
  • CHANGELOG.md - Release history
  • .git/ - Branch, tags, commits

This skill modifies:

  • packages/fpkit/package.json - Version field (Step 5)
  • CHANGELOG.md - Release notes (Step 6)
  • Git branches, tags (Steps 4, 8)

This skill publishes to:


Version Validation Steps

StepCheckCommand
1Get current versioncat packages/fpkit/package.json | grep version
2Check npm latestnpm view @fpkit/acss version
3View commit historygit log --oneline {last-tag}..HEAD
4Ask user for bump typepatch / minor / major
5Verify next version freenpm view @fpkit/acss@{next} version (expect 404)

OTP Authentication

Format: Exactly 6 numeric digits

RequirementDetails
Length6 digits (no more, no less)
CharactersNumeric only (0-9)
Expiry~30 seconds after generation
UsageSingle-use per publish

Best practices:

  • Generate OTP immediately before publishing
  • Don't wait >20 seconds before using code
  • Keep authenticator app ready
  • If expired, request fresh code (don't retry same)

See: references/technical-reference.md for OTP debugging


Helper Scripts

ScriptPurposeWhen to Use
scripts/pre-flight-check.shValidation onlyBefore starting workflow
scripts/publish-interactive.pyFull automated workflowGuided publish with OTP retry

Recommendation: Use interactive script for full automation and built-in error handling


Support & Resources

Common issues:

IssueSolutionReference
OTP expiredGenerate fresh code, retryreferences/troubleshooting.md
Build failedFix on main, restartreferences/detailed-workflow.md
Version existsChoose different versionreferences/troubleshooting.md
PR not mergedWait for review, don't skipreferences/detailed-workflow.md
Publish partialUse from-package flagreferences/rollback-recovery.md

External resources:

Reference files:

  • references/detailed-workflow.md - Step-by-step instructions for each workflow step
  • references/rollback-recovery.md - Recovery scenarios and fix-forward strategies
  • references/technical-reference.md - OTP, Lerna behavior, environment variables
  • references/workflow-examples.md - Real-world publish examples
  • references/troubleshooting.md - Error messages and solutions

END OF SKILL

スコア

総合スコア

50/100

リポジトリの品質指標に基づく評価

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

0/10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

レビュー

💬

レビュー機能は近日公開予定です