Prettier configuration validation and templates for package.json "prettier" field in MetaSaver monorepos. Includes 4 required standards (prettier field in package.json with string reference only, no separate prettierrc files, prettier in devDependencies, required npm scripts format and format:check). Use when creating or auditing Prettier configs to ensure consistent code formatting via shared library.
Inherits all available tools
Additional assets for this skill
This skill inherits all available tools. When active, it can use any tool Claude has access to.
templates/prettier-field.template.jsontemplates/prettierignore.templateThis skill provides package.json "prettier" field templates and validation logic for Prettier formatting setup.
Manage Prettier configuration to:
This skill is invoked by the prettier-agent when:
Standard templates are located at:
templates/prettier-field.template.json
templates/prettierignore.template
Must have "prettier" field with string reference only:
{
"prettier": "@metasaver/core-prettier-config/react"
}
OR for base projects:
{
"prettier": "@metasaver/core-prettier-config"
}
The prettier field maps to config type based on projectType:
| projectType | Config Type | Description |
|---|---|---|
| base | base | Minimal config (utilities) |
| node | base | Node.js backend services |
| web-standalone | react | Vite React web applications |
| react-library | react | React component libraries |
All Prettier rules and configuration complexity lives in the shared @metasaver/core-prettier-config library. Individual projects must NOT define inline config objects.
Configuration must be in package.json only:
.prettierrc, .prettierrc.json, .prettierrc.js, or similar filesException: Root .prettierignore file is REQUIRED (see Rule 4).
Must have in package.json devDependencies:
{
"devDependencies": {
"prettier": "^3.0.0",
"@metasaver/core-prettier-config": "workspace:*"
}
}
For monorepos, use workspace:* protocol to reference the shared config package.
npm Scripts:
Must include format scripts in package.json:
For packages:
{
"scripts": {
"format": "prettier --check .",
"format:check": "prettier --check .",
"format:fix": "prettier --write ."
}
}
For monorepo root:
{
"scripts": {
"format": "turbo run format",
"format:check": "turbo run format:check",
"format:fix": "turbo run format:fix"
}
}
Root .prettierignore:
Must have .prettierignore at repository root with essential patterns:
# Dependencies
node_modules
pnpm-lock.yaml
# Build outputs
dist
build
.next
.turbo
# Coverage
coverage
# OS
.DS_Store
To validate a Prettier configuration:
metasaver.projectType// Rule 1: Map projectType to config type
const typeMap = {
base: "base",
node: "base",
"web-standalone": "react",
"react-library": "react",
};
const expectedType = typeMap[projectType];
// Check prettier field exists and is string
const prettierField = packageJson.prettier;
if (!prettierField) {
errors.push("Rule 1: Missing 'prettier' field in package.json");
} else if (typeof prettierField !== "string") {
errors.push(
"Rule 1: prettier field must be string reference, not inline object",
);
} else {
// Verify correct config type
const expectedRef =
expectedType === "base"
? "@metasaver/core-prettier-config"
: "@metasaver/core-prettier-config/react";
if (prettierField !== expectedRef) {
errors.push(
`Rule 1: Expected "${expectedRef}" for projectType "${projectType}"`,
);
}
}
// Rule 2: Check for .prettierrc files
const prettierrcFiles = glob("**/.prettierrc*", {
ignore: ["node_modules/**"],
});
if (prettierrcFiles.length > 0) {
errors.push(
`Rule 2: Remove .prettierrc files: ${prettierrcFiles.join(", ")}`,
);
}
// Rule 3: Check dependencies
const deps = packageJson.devDependencies || {};
if (!deps["@metasaver/core-prettier-config"]) {
errors.push(
"Rule 3: Missing @metasaver/core-prettier-config in devDependencies",
);
}
if (!deps.prettier) {
errors.push("Rule 3: Missing prettier in devDependencies");
}
// Rule 4: Check npm scripts
const scripts = packageJson.scripts || {};
const isMonorepoRoot = !packageJson.name; // Root has no name
if (isMonorepoRoot) {
if (!scripts.format?.includes("turbo")) {
errors.push('Rule 4: Monorepo root must use "turbo run format"');
}
} else {
if (!scripts.format?.includes("prettier")) {
errors.push('Rule 4: Missing "format" script with prettier');
}
if (!scripts["format:check"]?.includes("prettier")) {
errors.push('Rule 4: Missing "format:check" script');
}
if (!scripts["format:fix"]?.includes("prettier")) {
errors.push('Rule 4: Missing "format:fix" script with --write');
}
}
// Rule 4: Check root .prettierignore (monorepo only)
if (isMonorepoRoot) {
const rootIgnore = fs.existsSync(".prettierignore");
if (!rootIgnore) {
errors.push("Rule 4: Missing .prettierignore at repository root");
}
}
Consumer repos may declare exceptions in package.json:
{
"metasaver": {
"exceptions": {
"prettier-config": {
"type": "custom-rules",
"reason": "Requires custom printWidth for legacy documentation files"
}
}
}
}
This skill integrates with:
scope parameter. If not provided, use /skill scope-check/skill audit-workflow - Bi-directional comparison workflow/skill remediation-options - Conform/Update/Ignore choiceseslint-agent - Coordination with ESLint style ruleseditorconfig-agent - Coordination with EditorConfig settings