From epieczko-betty
Format code using Prettier, supporting multiple languages and file types. This skill can format individual files or entire directories, check formatting without making changes, and respect custom Prettier configurations.
npx claudepluginhub joshuarweaver/cascade-code-general-misc-1 --plugin epieczko-bettyThis skill uses the workspace's default tool permissions.
Format code using Prettier, supporting multiple languages and file types. This skill can format individual files or entire directories, check formatting without making changes, and respect custom Prettier configurations.
Guides Next.js Cache Components and Partial Prerendering (PPR) with cacheComponents enabled. Implements 'use cache', cacheLife(), cacheTag(), revalidateTag(), static/dynamic optimization, and cache debugging.
Guides building MCP servers enabling LLMs to interact with external services via tools. Covers best practices, TypeScript/Node (MCP SDK), Python (FastMCP).
Generates original PNG/PDF visual art via design philosophy manifestos for posters, graphics, and static designs on user request.
Format code using Prettier, supporting multiple languages and file types. This skill can format individual files or entire directories, check formatting without making changes, and respect custom Prettier configurations.
Purpose: Automatically format code using Prettier to maintain consistent code style across your project.
Command: /code/format
Version: 0.1.0
Prettier must be installed either globally or locally in your project:
# Global installation
npm install -g prettier
# Or local installation (recommended)
npm install --save-dev prettier
Format a single file:
python3 skills/code.format/code_format.py --path src/index.js
Format an entire directory:
python3 skills/code.format/code_format.py --path src/
Check formatting without modifying files:
python3 skills/code.format/code_format.py --path src/ --check
Format only specific file types:
python3 skills/code.format/code_format.py --path src/ --patterns "**/*.ts,**/*.tsx"
Use custom Prettier configuration:
python3 skills/code.format/code_format.py --path src/ --config-path .prettierrc.custom
Dry run (check without writing):
python3 skills/code.format/code_format.py --path src/ --no-write
Output as YAML:
python3 skills/code.format/code_format.py --path src/ --output-format yaml
| Argument | Required | Default | Description |
|---|---|---|---|
--path | Yes | - | File or directory path to format |
--config-path | No | Auto-detect | Path to custom Prettier configuration file |
--check | No | false | Only check formatting without modifying files |
--patterns | No | All supported | Comma-separated glob patterns (e.g., "/*.js,/*.ts") |
--no-write | No | false | Don't write changes (dry run mode) |
--output-format | No | json | Output format: json or yaml |
The skill will automatically search for Prettier configuration files in this order:
--config-path.prettierrc in the target directory or parent directories.prettierrc.json, .prettierrc.yml, .prettierrc.yaml.prettierrc.js, .prettierrc.cjsprettier.config.js, prettier.config.cjsThe skill returns a JSON object with detailed formatting results:
{
"ok": true,
"status": "success",
"message": "Formatted 5 files. 3 already formatted.",
"formatted_count": 5,
"already_formatted_count": 3,
"needs_formatting_count": 0,
"checked_count": 8,
"error_count": 0,
"files_formatted": [
"src/components/Header.tsx",
"src/utils/helpers.js"
],
"files_already_formatted": [
"src/index.ts",
"src/App.tsx",
"src/config.json"
],
"files_need_formatting": [],
"files_with_errors": []
}
The skill gracefully handles various error scenarios:
Include this skill in your agent's configuration:
name: my.agent
version: 1.0.0
skills_available:
- code.format
Then invoke it programmatically:
from skills.code_format.code_format import CodeFormat
formatter = CodeFormat()
result = formatter.execute(
path="src/",
check_only=True,
file_patterns="**/*.{ts,tsx}"
)
if result["ok"]:
print(f"Checked {result['checked_count']} files")
print(f"{result['needs_formatting_count']} files need formatting")
python3 skills/code.format/code_format.py \
--path src/ \
--patterns "**/*.{js,jsx,ts,tsx,css,json}"
python3 skills/code.format/code_format.py \
--path src/ \
--check \
--output-format json
# Exit code 0 if all files formatted, 1 otherwise
# Get changed files from git
CHANGED_FILES=$(git diff --name-only --diff-filter=ACMR | grep -E '\.(js|ts|jsx|tsx)$' | tr '\n' ',')
# Format only those files
python3 skills/code.format/code_format.py \
--path . \
--patterns "$CHANGED_FILES"
Run the test suite:
pytest skills/code.format/test_code_format.py -v
Run specific tests:
pytest skills/code.format/test_code_format.py::TestCodeFormat::test_single_file -v
This skill requires the following permissions:
Produces:
formatting-report (application/json) - Detailed formatting operation resultsIssue: "Prettier is not installed"
npm install -g prettier) or locally in your projectIssue: No files found to format
Issue: Configuration file not found
Issue: Timeout errors
This skill was generated by meta.skill, the skill creator meta-agent, and enhanced with full Prettier integration.
Part of the Betty Framework