ams-yarn-pro
暂无简介
- License 许可
- MIT
- 最近更新
- 2026-11-07
- Stars
- ★ 0
- Forks
- 1
03 SKILL.md 正文
Yarn Pro
A practical guide to Yarn — primarily modern Yarn Berry (v2+): Plug'n'Play, workspaces, constraints, and the release workflow, plus notes for teams still on Yarn Classic (v1).
Overview
Yarn Berry rethought package management: Plug'n'Play (PnP) eliminates node_modules entirely (packages load from zip archives via a loader), constraints enforce workspace consistency with Prolog-like rules, and releases are checked into the repo (yarn set version) so everyone runs the identical Yarn. It's powerful but opinionated — editor SDKs and some tools need explicit setup for PnP.
Know which Yarn you have: yarn --version — v1.x is Classic (node_modules, still common), v2+ is Berry.
When to use
- Monorepos wanting strong consistency guarantees (constraints) and fast installs.
- Zero-install workflows (check in
.yarn/cachefor instant CI). - Teams hitting phantom-dependency or version-drift issues.
- Migrating from Classic to Berry, or maintaining a Classic repo.
Core concepts
- Plug'n'Play. No
node_modules;.pnp.cjsmaps packages to zip locations. Strict: undeclared deps fail at runtime. Editor support viayarn dlx @yarnpkg/sdks. - Zero-installs. Commit
.yarn/cache(zips) →yarn installbecomes nearly instant, CI needs no network. Costs repo size; worth it for many teams. - Workspaces. Like other managers, plus
yarn workspaces foreachfor running commands across packages with topological ordering. - Constraints (
constraints.pro). Declarative rules: "all workspaces must use the same version of react", "no workspace may depend on X".yarn constraintschecks;yarn constraints --fixrepairs. packageExtensions. Fix packages with missing peer deps declaratively in.yarnrc.ymlinstead of forking — but prefer upstream fixes long-term.- Release workflow.
yarn version check/yarn version applymanage deferred version bumps across workspaces; pairs with release plugins. - Classic (v1).
node_modules+yarn.lock; workspaces exist but are thinner. Still fine; just lacks Berry's strictness tooling.
Practical workflow
1. Setup (Berry).
yarn init -2 # or: yarn set version stable in existing repo
echo 'nodeLinker: pnp' >> .yarnrc.yml # or node-modules if PnP fights your tools
yarn install
2. Daily commands.
yarn add react # add dep
yarn add -D typescript # devDep
yarn up react # upgrade across workspaces
yarn dedupe # reduce duplicates
yarn why react # explain a dependency
yarn workspaces foreach -R --topological-dev run build
yarn constraints --fix # enforce consistency rules
3. .yarnrc.yml essentials.
nodeLinker: pnp
packageExtensions:
"some-lib@*":
peerDependencies: { "react": "*" }
4. Editor SDKs (PnP).
yarn dlx @yarnpkg/sdks vscode vim # generates editor SDKs so TS/eslint resolve PnP
Without this, TypeScript and ESLint can't find packages under PnP.
5. CI.
yarn install --immutable # fail if lockfile would change
Common pitfalls
- PnP vs tooling. Some tools assume
node_modulesexists. Options:nodeLinker: node-modules(pragmatic), orpackageExtensions+ SDKs. Don't suffer silently — pick the linker that fits your toolchain. - Skipping editor SDKs. Red squiggles everywhere under PnP = missing SDKs, not broken code. Run the SDK generator.
- Undeclared deps. Same strictness lesson as pnpm:
Cannot find module→ declare the dependency properly. - Zero-install repo bloat.
.yarn/cachecan grow large; useyarn cache clean --allequivalents judiciously and considerenableGlobalCachefor huge monorepos. - Constraints ignored. Writing
constraints.probut never runningyarn constraintsin CI = documentation, not enforcement. Gate CI on it. - Classic/Berry confusion. Docs and Stack Overflow answers differ wildly by version. Always check which major version an answer targets.
- Forgetting
--immutablein CI. Without it, CI may update the lockfile instead of failing on drift — the opposite of what you want. - Overriding with resolutions carelessly.
resolutionsforce versions globally — powerful for fixing CVEs fast, dangerous as a permanent crutch. Prefer upstream fixes.
04 同仓库更多 Skills
web-scrape
Turn web pages into LLM-ready markdown via the Firecrawl API (renders JS, anti-bot handling). Use when browser_open/fetch fails on JS-heavy pages, or when you need clean markdown/structured extraction from a site. Requires FIRECRAWL_API_KEY.
design-taste-frontend
tasteskill v2, the anti-slop frontend skill. Art direction for websites, distilled from a study of 247 curated gallery sites (One Page Love, Awwwards Sites of the Day). Deals researched directions (idea, composition, type, palette, photographs, section blueprints) from a library, enforces a strict no-slop house style with a real-browser inspector, and runs a look-and-fix loop on screenshots. Use this whenever you build, design, redesign, restyle, polish or review a landing page, marketing site, portfolio, product page, one-pager, hero or any public-facing web page, in any stack (HTML/CSS, React, Next.js, Vue, Svelte, Astro, Tailwind) — also when the user says a page looks generic, templated, "AI-made", sloppy, or asks to make it look designed, premium, award-level or less like every other site. Not for dashboards or app screens.
test-driven-development
Use when implementing any feature or bugfix, before writing implementation code
systematic-debugging
Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes
requesting-code-review
Use when completing tasks, implementing major features, or before merging to verify work meets requirements
brainstorming
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).