Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .claude-plugin/marketplace.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,21 @@
"name": "astral",
"source": "./plugins/astral",
"description": "Skills for working with Python using Astral tools."
},
{
"name": "ruff-format",
"source": "./plugins/ruff-format",
"description": "Auto-format Python files with ruff after edits."
},
{
"name": "cargo-format",
"source": "./plugins/cargo-format",
"description": "Auto-format Rust files with cargo fmt after edits."
},
{
"name": "prettier-format",
"source": "./plugins/prettier-format",
"description": "Auto-format files with prettier after edits."
}
]
}
45 changes: 45 additions & 0 deletions plugins/cargo-format/.claude-plugin/hooks/post-edit-format.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# /// script
# requires-python = ">=3.12"
# dependencies = []
# ///

"""Post-edit hook to auto-format Rust files with cargo fmt."""

import json
import os
import subprocess
import sys
from pathlib import Path


def main() -> None:
input_data = json.load(sys.stdin)

tool_name = input_data.get("tool_name")
tool_input = input_data.get("tool_input", {})
file_path = tool_input.get("file_path")

if tool_name not in ("Write", "Edit", "MultiEdit"):
return

if not file_path:
return

path = Path(file_path)
if path.suffix != ".rs":
return

cwd = os.environ.get("CLAUDE_PROJECT_DIR", os.getcwd())

try:
subprocess.run(
["cargo", "fmt", "--", file_path],
cwd=cwd,
capture_output=True,
)
except FileNotFoundError:
pass


if __name__ == "__main__":
main()
19 changes: 19 additions & 0 deletions plugins/cargo-format/.claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "cargo-format",
"description": "Auto-format Rust files with cargo fmt after edits.",
"version": "0.1.0",
"author": {
"name": "Astral",
"url": "https://astral.sh"
},
"repository": "https://github.com/astral-sh/claude-code-plugins",
"license": "MIT",
"keywords": ["rust", "cargo", "formatting"],
"hooks": [
{
"type": "PostToolUse",
"command": "python",
"args": [".claude-plugin/hooks/post-edit-format.py"]
}
]
}
45 changes: 45 additions & 0 deletions plugins/prettier-format/.claude-plugin/hooks/post-edit-format.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# /// script
# requires-python = ">=3.12"
# dependencies = []
# ///

"""Post-edit hook to auto-format files with prettier."""

import json
import os
import subprocess
import sys
from pathlib import Path


def main() -> None:
input_data = json.load(sys.stdin)

tool_name = input_data.get("tool_name")
tool_input = input_data.get("tool_input", {})
file_path = tool_input.get("file_path")

if tool_name not in ("Write", "Edit", "MultiEdit"):
return

if not file_path:
return

path = Path(file_path)
if path.suffix not in (".json5", ".yaml", ".yml", ".md"):
return

cwd = os.environ.get("CLAUDE_PROJECT_DIR", os.getcwd())

try:
subprocess.run(
["npx", "prettier", "--write", file_path],
cwd=cwd,
capture_output=True,
)
except FileNotFoundError:
pass


if __name__ == "__main__":
main()
15 changes: 15 additions & 0 deletions plugins/prettier-format/.claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "prettier-format",
"description": "Auto-format files with prettier after edits.",
"version": "0.1.0",
"repository": "https://github.com/astral-sh/claude-code-plugins",
"license": "MIT",
"keywords": ["prettier", "formatting", "json", "yaml", "markdown"],
"hooks": [
{
"type": "PostToolUse",
"command": "python",
"args": [".claude-plugin/hooks/post-edit-format.py"]
}
]
}
45 changes: 45 additions & 0 deletions plugins/ruff-format/.claude-plugin/hooks/post-edit-format.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# /// script
# requires-python = ">=3.12"
# dependencies = []
# ///

"""Post-edit hook to auto-format Python files with ruff."""

import json
import os
import subprocess
import sys
from pathlib import Path


def main() -> None:
input_data = json.load(sys.stdin)

tool_name = input_data.get("tool_name")
tool_input = input_data.get("tool_input", {})
file_path = tool_input.get("file_path")

if tool_name not in ("Write", "Edit", "MultiEdit"):
return

if not file_path:
return

path = Path(file_path)
if path.suffix not in (".py", ".pyi"):
return

cwd = os.environ.get("CLAUDE_PROJECT_DIR", os.getcwd())

try:
subprocess.run(
["uvx", "ruff", "format", file_path],
cwd=cwd,
capture_output=True,
)
except FileNotFoundError:
pass


if __name__ == "__main__":
main()
20 changes: 20 additions & 0 deletions plugins/ruff-format/.claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "ruff-format",
"description": "Auto-format Python files with ruff after edits.",
"version": "0.1.0",
"author": {
"name": "Astral",
"url": "https://astral.sh"
},
"homepage": "https://docs.astral.sh/ruff/",
"repository": "https://github.com/astral-sh/claude-code-plugins",
"license": "MIT",
"keywords": ["ruff", "python", "formatting"],
"hooks": [
{
"type": "PostToolUse",
"command": "python",
"args": [".claude-plugin/hooks/post-edit-format.py"]
}
]
}