Skillshub code-formatter
install
source · Clone the upstream repo
git clone https://github.com/ComeOnOliver/skillshub
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ComeOnOliver/skillshub "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/jeremylongshore/claude-code-plugins-plus-skills/code-formatter" ~/.claude/skills/comeonoliver-skillshub-code-formatter-6793ae && rm -rf "$T"
manifest:
skills/jeremylongshore/claude-code-plugins-plus-skills/code-formatter/SKILL.mdsource content
Code Formatter
Overview
Formats and validates code files using Prettier and related formatting tools. Supports JavaScript, TypeScript, JSON, CSS, Markdown, and many other file types.
Prerequisites
- Node.js (v16+) and npm/npx installed
- Prettier available globally (
) or locally in the projectnpm install -g prettier - Write permissions for target files and configuration directories
- Supported file types present in the project (
,.js
,.jsx
,.ts
,.tsx
,.json
,.css
).md
Instructions
- Check whether Prettier is available by running
. If missing, install it locally withnpx prettier --version
or globally withnpm install --save-dev prettier
.npm install -g prettier - Detect existing configuration by searching for
,.prettierrc
,.prettierrc.json
, or aprettier.config.js
key in"prettier"
. If no configuration exists, create apackage.json
with sensible defaults (see.prettierrc
).${CLAUDE_SKILL_DIR}/references/implementation.md - Run
to identify files that need formatting. Report the count and list of non-conforming files.npx prettier --check "**/*.{js,jsx,ts,tsx,json,css,md}" --ignore-path .prettierignore - Apply formatting to identified files using
on the target paths. For single files, specify the exact path; for directories, use glob patterns.npx prettier --write - Create or update
to exclude generated outputs (.prettierignore
,dist/
,build/
,*.min.js
), dependencies (*.min.css
,node_modules/
), and lock files.vendor/ - Optionally set up pre-commit enforcement by installing
andhusky
, then configuringlint-staged
inlint-staged
to runpackage.json
on staged files matching supported extensions.prettier --write - Run a final
to confirm all target files now conform to the configured style rules.npx prettier --check
Output
A formatting execution report containing:
- Count of files checked and files reformatted
- List of files that were modified with before/after formatting status
- Configuration file(s) created or updated (
,.prettierrc
).prettierignore - Any git hook integration changes applied
- Confirmation of final formatting compliance
Error Handling
| Error | Cause | Solution |
|---|---|---|
| Prettier not installed globally or locally | Run or to use npx |
| Syntax errors in source files | Malformed code that Prettier cannot parse | Fix syntax errors first using then retry formatting |
| Configuration conflicts | Multiple files or conflicting | Locate all config files with and consolidate to a single config |
| Permission denied on write | File or directory lacks write permission | Run to grant write access |
| Parser not found for file type | Unsupported file extension or missing Prettier plugin | Install the appropriate Prettier plugin (e.g., ) or exclude the file type |
Examples
Format a single file: Trigger: "Format src/app.js" Process: Run
npx prettier --write src/app.js. Report the file as reformatted or already conformant.
Project-wide formatting setup: Trigger: "Set up code formatting for this project." Process: Create
.prettierrc with project defaults, create .prettierignore excluding build outputs, run npx prettier --write "src/**/*.{js,ts,json,css}", install husky and lint-staged for pre-commit hooks, verify compliance.
Check formatting without modifying files: Trigger: "Check formatting across the project." Process: Run
npx prettier --check "**/*.{js,jsx,ts,tsx,json,css,md}". Report non-conforming files with their paths. Suggest npx prettier --write to fix.
Resources
-- detailed implementation guide with configuration examples${CLAUDE_SKILL_DIR}/references/implementation.md
-- common error scenarios and solutions${CLAUDE_SKILL_DIR}/references/errors.md- Prettier documentation -- official configuration and CLI reference
- ESLint -- complementary linting and code quality tool
- Husky -- git hooks for pre-commit formatting enforcement