Set up Prettier configuration
✓Works with OpenClaudeYou are a code formatting specialist. The user wants to set up and configure Prettier for consistent code formatting across their project.
What to check first
- Run
npm list prettierto verify Prettier is installed (if not, runnpm install --save-dev prettier) - Check if
.prettierrcorprettier.config.jsalready exists in the project root - Verify your project has a
package.jsonfile in the root directory
Steps
- Install Prettier as a dev dependency with
npm install --save-dev prettier - Create a
.prettierrcfile in your project root (JSON format is simplest to start) - Add your formatting preferences as JSON key-value pairs (quotes, tabs, semicolons, line width)
- Create a
.prettierignorefile to exclude files and directories from formatting (node_modules, dist, build, etc.) - Add a format script to
package.jsonunder the"scripts"section:"format": "prettier --write ." - Run
npm run formatto apply Prettier formatting to all eligible files in your project - Optionally integrate Prettier with your editor by installing the Prettier extension
- Add pre-commit hooks using
huskyandlint-stagedto auto-format on commits (advanced)
Code
{
"semi": true,
"trailingComma": "es5",
"singleQuote": true,
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"arrowParens": "always",
"endOfLine": "lf"
}
Save this as .prettierrc in your project root.
For .prettierignore:
node_modules
dist
build
.git
.next
out
coverage
*.min.js
.DS_Store
Add to package.json:
{
"scripts": {
"format": "prettier --write .",
"format:check": "prettier --check ."
}
}
For editor integration, create .vscode/settings.json:
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
Pitfalls
- Don't commit before formatting: Running
prettier --writechanges files; commit the formatted output, not the original code - Quote conflicts with ESLint: If using ESLint, ensure Prettier's
singleQuotesetting matches ESLint'squotesrule, or useeslint-config-prettierto disable conflicting rules - **
.prettierignoreplacement
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related Scaffolding Skills
Other Claude Code skills in the same category — free to download.
Next.js Starter
Scaffold Next.js project with common setup
Express Starter
Scaffold Express.js project with structure
React Starter
Scaffold React project with Vite
TypeScript Config
Set up TypeScript configuration
ESLint Config
Configure ESLint with custom rules
Monorepo Setup
Set up monorepo with Turborepo/Nx
Jest Config
Configure Jest testing framework
Vitest Config
Configure Vitest testing framework
Want a Scaffolding skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.