prettier-formatting
Skill2 starsChanged 4 months agoMITView on GitHub
Prettier code formatting setup, configuration, editor integration, ESLint coordination, and pre-commit hook automation for consistent codebases. Use when the task involves `Prettier`, `code formatting`, `.prettierrc`, `Prettier configuration`, or `auto-formatting`.
- Installs packages
In this repository43 other files it gives its agents.
- accessibilitySkill
- best-practicesSkill
- brainstormingSkill
- core-web-vitalsSkill
- cypress-e2eSkill
- docker-expertSkill
- drizzle-ormSkill
- elixir-developmentSkill
- eslint-configSkill
- express-apiSkill
- frontend-designSkill
- github-actionsSkill
- go-developmentSkill
- grafana-dashboardsSkill
- grpc-apiSkill
- helm-chartsSkill
- jest-testingSkill
- kubernetes-orchestrationSkill
- makefileSkill
- markdown-a11ySkill
- nothing-designSkill
- performanceSkill
- php-developmentSkill
- pinned-tagSkill
- postgresql-developmentSkill
- pr-creatorSkill
- pydanticSkill
- qwik-developmentSkill
- rails-developmentSkill
- ruby-developmentSkill
- rust-async-patternsSkill
- seoSkill
- skill-creatorSkill
- solidjs-developmentSkill
- sqlalchemySkill
- sql-optimization-patternsSkill
- swift-ios-developmentSkill
- tensorflow-mlSkill
- testing-librarySkill
- trpc-type-safetySkill
- webapp-testingSkill
- web-quality-auditSkill
- zig-developmentSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
15 rules. About 0 are common, 5 are distinctive, and 10 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
10
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 26
ESLint Separation: Use eslint-config-prettier to disable ESLint formatting rules.
- Very specific: line 29
Ignore Correctly: Always create .prettierignore to skip generated files, build output, and lock files.
- Distinctive: line 33
Format All or Nothing: When adding Prettier to an existing project, do one full format commit.
- Distinctive: line 34
Never mix formatting changes with logic changes in the same commit.
- Very specific: line 35
Pre-Commit Enforcement: Use lint-staged + husky (or lefthook) to format only staged files.
- Very specific: line 207
Create a .prettierrc.json (or .prettierrc) at the project root — explicit config prevents editor-level settings from causing inconsistency.
- Very specific: line 209
Run prettier --check . in CI to catch unformatted code before merge.
- Very specific: line 210
Use overrides for file types that need different settings (Markdown prose, YAML indentation).
- Very specific: line 211
Add .vscode/settings.json with formatOnSave: true to the repo so all contributors get it.
- Distinctive: line 212
Do one big "format the world" commit when onboarding Prettier, then enforce from that point.
- Very specific: line 216
Don't install eslint-plugin-prettier — it runs Prettier inside ESLint, doubling execution time and mixing formatting with linting concerns.
- Very specific: line 218
Don't format lock files (pnpm-lock.yaml, package-lock.json) — it breaks integrity checksums.
- Distinctive: line 219
Don't customize every option — Prettier's defaults are battle-tested.
- Very specific: line 221
Don't skip .prettierignore — without it, Prettier will try to format generated files, SVGs, and build output, causing noise and errors.
- Distinctive: line 223
Don't mix formatting changes with logic changes in pull requests — reviewers can't distinguish what actually changed.
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
When to Use
- Setting up Prettier in a new or existing project for consistent formatting.
- Configuring
.prettierrcoptions to match team style preferences. - Integrating Prettier with ESLint without rule conflicts.
- Adding format-on-save in VS Code, JetBrains, or other editors.
- Setting up pre-commit hooks to enforce formatting before code is committed.
- Adding file-type-specific overrides (e.g., different
printWidthfor Markdown vs TypeScript).
Critical Patterns
- Prettier Decides, You Don't Argue: Prettier is intentionally opinionated. Configure only the options it exposes — do NOT fight its AST-based formatting decisions with hacks.
- ESLint Separation: Use
eslint-config-prettierto disable ESLint formatting rules. Do NOT useeslint-plugin-prettier— it's slow and mixes concerns. Run Prettier and ESLint as separate steps. - Ignore Correctly: Always create
.prettierignoreto skip generated files, build output, and lock files. Prettier reads.gitignoreby default, but explicit ignores prevent accidents. - Pin the Version: Lock the Prettier version in
package.jsonto avoid formatting churn across developer machines and CI. - Format All or Nothing: When adding Prettier to an existing project, do one full format commit. Never mix formatting changes with logic changes in the same commit.
- Pre-Commit Enforcement: Use
lint-staged+husky(orlefthook) to format only staged files. Running Prettier on the entire repo per commit is wasteful.
Code Examples
Configuration (.prettierrc.json)
{
"printWidth": 100,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": true,
"trailingComma": "all",
"bracketSpacing": true,
"arrowParens": "always",
"endOfLine": "lf",
"proseWrap": "preserve",
"htmlWhitespaceSensitivity": "css",
"singleAttributePerLine": false
}File-Type Overrides
{
"printWidth": 100,
"singleQuote": true,
"trailingComma": "all",
"overrides": [
{
"files": "*.md",
"options": {
"printWidth": 80,
"proseWrap": "always"
}
},
{
"files": ["*.json", "*.jsonc"],
"options": {
"tabWidth": 2,
"trailingComma": "none"
}
},
{
"files": "*.yaml",
"options": {
"tabWidth": 2,
"singleQuote": false
}
}
]
}.prettierignore
# Build output
dist/
build/
.next/
out/
# Dependencies
node_modules/
# Lock files (formatting breaks checksums)
pnpm-lock.yaml
package-lock.json
yarn.lock
# Generated
coverage/
*.generated.*
*.min.js
*.min.css
# Assets
*.svg
*.png
*.icoESLint Integration (Conflict-Free)
# Install only the config disabler — NOT the plugin
npm install -D eslint-config-prettier// eslint.config.js
import prettier from "eslint-config-prettier";
export default [
// ... your other configs
prettier, // MUST be last — disables ESLint rules that conflict with Prettier
];Pre-Commit Hook with lint-staged
// package.json
{
"lint-staged": {
"*.{js,ts,tsx,jsx,json,css,md,yaml}": "prettier --write"
}
}# Setup with Husky
npm install -D husky lint-staged
npx husky init
echo "npx lint-staged" > .husky/pre-commit# Or with Lefthook (lefthook.yml)
pre-commit:
commands:
prettier:
glob: "*.{js,ts,tsx,jsx,json,css,md,yaml}"
run: npx prettier --write {staged_files} && git add {staged_files}VS Code Settings
// .vscode/settings.json
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"[markdown]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}Commands
# Format all files
npx prettier --write .
# Check without writing (for CI)
npx prettier --check .
# Format specific file types
npx prettier --write "src/**/*.{ts,tsx}"
# Show what would change
npx prettier --list-different .
# Debug: show resolved config for a file
npx prettier --find-config-path src/index.ts
# Debug: show which parser Prettier uses
npx prettier --file-info src/index.tsBest Practices
DO
- Create a
.prettierrc.json(or.prettierrc) at the project root — explicit config prevents editor-level settings from causing inconsistency. - Run
prettier --check .in CI to catch unformatted code before merge. - Use
overridesfor file types that need different settings (Markdown prose, YAML indentation). - Add
.vscode/settings.jsonwithformatOnSave: trueto the repo so all contributors get it. - Do one big "format the world" commit when onboarding Prettier, then enforce from that point.
DON'T
- Don't install
eslint-plugin-prettier— it runs Prettier inside ESLint, doubling execution time and mixing formatting with linting concerns. - Don't format lock files (
pnpm-lock.yaml,package-lock.json) — it breaks integrity checksums. - Don't customize every option — Prettier's defaults are battle-tested. Only change what your team truly needs.
- Don't skip
.prettierignore— without it, Prettier will try to format generated files, SVGs, and build output, causing noise and errors. - Don't mix formatting changes with logic changes in pull requests — reviewers can't distinguish what actually changed.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

