From ml-research
Format Python code with ruff formatter and optionally fix auto-fixable linting issues. Use when formatting code, preparing code for commit, or ensuring consistent code style across the project.
npx claudepluginhub nishide-dev/claude-code-ml-researchThis skill uses the workspace's default tool permissions.
Format Python code with ruff formatter and optionally fix auto-fixable linting issues.
Verifies tests pass on completed feature branch, presents options to merge locally, create GitHub PR, keep as-is or discard; executes choice and cleans up worktree.
Guides root cause investigation for bugs, test failures, unexpected behavior, performance issues, and build failures before proposing fixes.
Writes implementation plans from specs for multi-step tasks, mapping files and breaking into TDD bite-sized steps before coding.
Share bugs, ideas, or general feedback.
Format Python code with ruff formatter and optionally fix auto-fixable linting issues.
Ask the user what to format:
src/, tests/)If not specified, format all Python files in the project.
Format code with ruff:
# Format all files
uv run ruff format .
# Format specific directory
uv run ruff format src/
# Format specific files
uv run ruff format src/train.py src/models/model.py
# Preview changes without applying (dry-run)
uv run ruff format --check --diff .
Output interpretation:
After formatting, optionally fix auto-fixable linting issues:
# Fix all auto-fixable issues
uv run ruff check --fix .
# Fix specific directory
uv run ruff check --fix src/
# Fix specific rules only
uv run ruff check --fix --select F,I . # Fix imports and undefined names
Output interpretation:
After formatting and fixing, verify the results:
# Check formatting is correct
uv run ruff format --check .
# Check remaining lint issues
uv run ruff check .
Report any remaining issues that need manual attention.
If working in a git repository, show what changed:
# Show modified files
git status --short
# Show diff of changes (optional, if user wants to review)
git diff
Inform user about changes so they can review before committing.
To preview changes without applying:
# Show what would be formatted
uv run ruff format --check .
# Show detailed diff
uv run ruff format --check --diff .
Use this when user wants to see changes before applying.
To fix only specific types of issues:
# Fix only import order
uv run ruff check --fix --select I .
# Fix only unused imports
uv run ruff check --fix --select F401 .
# Fix only whitespace issues
uv run ruff check --fix --select W .
For more aggressive formatting (use with caution):
# Format with maximum line length
uv run ruff format --line-length 120 .
# Note: This overrides project config, confirm with user first
# Get list of changed Python files
changed_files=$(git diff --name-only --diff-filter=ACMR "*.py")
if [ -n "$changed_files" ]; then
# Format only changed files
echo "$changed_files" | xargs uv run ruff format
echo "$changed_files" | xargs uv run ruff check --fix
else
echo "No Python files changed"
fi
Suggest setting up pre-commit hooks:
# Install pre-commit (if using)
uv run pre-commit install
# Run hooks manually
uv run pre-commit run --all-files
If commands fail:
ruff not found:
uv add --dev ruffpixi add ruffSyntax errors in code:
Permission errors:
uv not found:
python -m ruff format .Formatting Python files with ruff...
✓ Formatted 15 files, 3 files left unchanged
Fixing auto-fixable lint issues...
✓ Fixed 8 violations
⚠ 2 violations remaining (need manual fix):
- src/train.py:45:1 F841 Local variable 'x' is assigned but never used
- src/model.py:12:5 E501 Line too long (95 > 88 characters)
Summary:
✓ Code formatted successfully
✓ 8 issues auto-fixed
⚠ 2 issues need manual attention
To review changes: git diff
To commit changes: git add -A && git commit -m "Format code with ruff"
ml-lint: Run code quality checks without modifying filesml-validate: Comprehensive project validation including code quality