Quick start
Set up with an AI agent
Section titled “Set up with an AI agent”Install
Section titled “Install”Install monoswan at the workspace root.
# pnpmpnpm add -D -w monoswan
# npmnpm install -D monoswan
# yarnyarn add -D -W monoswan
# bunbun add -D monoswanThe workspace root must contain pnpm-workspace.yaml or a workspaces declaration in
package.json.
Workspace discovery supports pnpm workspace files, npm and Bun workspace arrays, and both Yarn workspace forms, including modern Yarn Plug’n’Play installations. monoswan reads the declaration directly and does not invoke the package manager during discovery.
Add a configuration
Section titled “Add a configuration”Create monoswan.config.ts in the repository root.
import { defineConfig, enforceVariants } from "monoswan";
export default defineConfig({ variants: { "my-library": { packageJson: { scripts: { build: "tsdown", check: "tsc --noEmit", }, }, tsConfig: { compilerOptions: { strict: true, }, }, }, }, rules: [enforceVariants()],});The filename must be monoswan.config.ts or monoswan.config.mts.
Assign a variant
Section titled “Assign a variant”Add a monoswan field to a workspace package’s package.json or define a monoswan.json in the root of the package.
package.json
{ "name": "@myrepo/example", "monoswan": { "variants": ["my-library"] }}monoswan.json
{ "variants": ["my-library"]}You may compose variants: "variants": ["base", "my-library"], where each variant is merged.
Add workspace scripts
Section titled “Add workspace scripts”Add scripts to the workspace root package.json so linting and autofixing use the locally
installed monoswan version:
"scripts": { "monoswan": "monoswan lint .", "monoswan:fix": "monoswan lint . --fix"}Lint the workspace
Section titled “Lint the workspace”Run the script with your package manager:
# pnpmpnpm monoswan
# npmnpm run monoswan
# yarnyarn monoswan
# bunbun run monoswanRun the corresponding monoswan:fix script to apply available fixes before reporting remaining
issues.
