Skip to content

Quick start

Quick start with an agentGive your agent the context it needs to configure monoswan quickly.

Install monoswan at the workspace root.

Terminal window
# pnpm
pnpm add -D -w monoswan
# npm
npm install -D monoswan
# yarn
yarn add -D -W monoswan
# bun
bun add -D monoswan

The 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.

Create monoswan.config.ts in the repository root.

monoswan.config.ts
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.

Add a monoswan field to a workspace package’s package.json or define a monoswan.json in the root of the package.

package.json

package.json
{
"name": "@myrepo/example",
"monoswan": {
"variants": ["my-library"]
}
}

monoswan.json

monoswan.json
{
"variants": ["my-library"]
}

You may compose variants: "variants": ["base", "my-library"], where each variant is merged.

Add scripts to the workspace root package.json so linting and autofixing use the locally installed monoswan version:

package.json
"scripts": {
"monoswan": "monoswan lint .",
"monoswan:fix": "monoswan lint . --fix"
}

Run the script with your package manager:

Terminal window
# pnpm
pnpm monoswan
# npm
npm run monoswan
# yarn
yarn monoswan
# bun
bun run monoswan

Run the corresponding monoswan:fix script to apply available fixes before reporting remaining issues.