format-js

Format JavaScript/TypeScript code with Prettier

23 stars

Best use case

format-js is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Format JavaScript/TypeScript code with Prettier

Teams using format-js should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/format-js/SKILL.md --create-dirs "https://raw.githubusercontent.com/wangjianjq/Skill/main/.agents/skills/format-js/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/format-js/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How format-js Compares

Feature / Agentformat-jsStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Format JavaScript/TypeScript code with Prettier

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# JavaScript/TypeScript Format Skill

## 📋 Overview

Use **Prettier** to automatically format JavaScript and TypeScript code:

- 🎨 **Consistent style**: Unified formatting across multiple file types
- ⚡ **Fast execution**: Millisecond-level formatting speed
- 🔧 **Out of the box**: Reasonable default configuration
- 🌈 **Wide support**: JS, TS, JSX, TSX, JSON, CSS, etc.

## 🔧 Prerequisites

| Tool | Min Version | Check Command | Installation |
|------|-------------|---------------|--------------|
| Node.js | 16+ | `node --version` | [nodejs.org](https://nodejs.org) |
| Prettier | 2.8+ | `prettier --version` | `npm install -g prettier` |

## 🚀 Usage

### Method 1: AI Assistant

```
"Use format-js to format my JavaScript code"
```

### Method 2: Run Script Directly

```powershell
# Windows
.\.agents\skills\format-js\scripts\format.ps1

# Linux/Mac
./.agents/skills/format-js/scripts/format.sh
```

### Method 3: With Parameters

```powershell
# Check without modifying
.\.agents\skills\format-js\scripts\format.ps1 -Check

# Format specific file types
.\.agents\skills\format-js\scripts\format.ps1 -Extensions "js,ts,jsx,tsx"
```

## 🎯 What It Formats

- ✅ Indentation and spacing
- ✅ Quote unification (single/double)
- ✅ Line length limits
- ✅ Semicolon add/remove
- ✅ Bracket and comma normalization
- ✅ Arrow function formatting

> **Safety Gate**: By default, this skill skips protected folders (`.agents/`, `bmad/`) and `README.md`.

## ⚙️ Configuration

```json
// .prettierrc
{
  "semi": true,
  "singleQuote": true,
  "tabWidth": 2,
  "trailingComma": "es5",
  "printWidth": 80,
  "arrowParens": "avoid"
}
```

## 🔗 Related Resources

- [Prettier Documentation](https://prettier.io/)
- [Prettier Playground](https://prettier.io/playground/)