- **Clear feedback**: Explain what validations ran and their results
Resources
1Install
npx skillscat add gotar/opencode-config/skills-commit Install via the SkillsCat registry.
SKILL.md
Commit Skill - Dynamic Pre-Commit Validation
You are an AI agent that helps create well-formatted git commits with conventional commit messages and emoji icons. This updated version uses dynamic pre-commit validation based on file types and LSP detection.
Instructions for Agent
When the user runs this command, execute the following workflow:
Check command mode:
- If user provides (a simple message), skip to step 3
Run dynamic pre-commit validation:
- Analyze staged files with
git diff --cached --name-only - For each file type, run appropriate validation:
- Python (.py): Run
mypy .orruff check .if available, else use LSP diagnostics - Ruby (.rb): Run
rubocopif available, else use LSP diagnostics - JavaScript/TypeScript (.js, .ts, .tsx): Run
eslint .ortsc --noEmitif available, else use LSP diagnostics - Go (.go): Run
go vet ./...orgolangci-lint runif available, else use LSP diagnostics - Rust (.rs): Run
cargo checkorcargo clippyif available, else use LSP diagnostics - Markdown (.md): Check for basic formatting issues (long lines, etc.) or use
markdownlintif available - Other text files: Use LSP diagnostics if LSP server available
- Python (.py): Run
- For all code files, run
lsp_diagnosticsto check for errors/warnings - If any validation fails, ask user if they want to proceed anyway or fix issues first
- Analyze staged files with
Analyze git status:
- Run
git status --porcelainto check for changes - If no files are staged, run
git add .to stage all modified files - If files are already staged, proceed with only those files
- Run
Analyze the changes:
- Run
git diff --cachedto see what will be committed - Analyze the diff to determine the primary change type (feat, fix, docs, etc.)
- Identify the main scope and purpose of the changes
- Run
Generate commit message:
- Choose appropriate emoji and type from the reference below
- Create message following format:
<emoji> <type>: <description> - Keep description concise, clear, and in imperative mood
- Show the proposed message to user for confirmation
Execute the commit:
- Run
git commit -m "<generated message>" - Display the commit hash and confirm success
- Provide brief summary of what was committed
- Push with
git push
- Run
Dynamic Validation Logic
File Type Detection
Use file extensions to determine validation strategy:
.py→ Python validation.rb→ Ruby validation.js,.ts,.tsx→ JavaScript/TypeScript validation.go→ Go validation.rs→ Rust validation.md→ Markdown validation- Other → Generic LSP check
Tool Availability Check
For each validation type, check if tools are available:
which mypy || which ruff || echo "No Python linter found"
which rubocop || echo "No Ruby linter found"
which eslint || which tsc || echo "No JS/TS linter found"
# etc.LSP Fallback
If specific tools not available, use LSP diagnostics:
- Run
lsp_diagnosticson each changed file - Check for errors, warnings, hints
- Report any issues found
Markdown Validation
For .md files:
- Check line lengths (warn if >100 characters)
- Basic structure validation
- Use
markdownlintif available, else basic checks
Error Handling
- If validation tools missing: Use LSP fallback or skip with warning
- If LSP not available: Skip validation with note to user
- If validation fails: Ask user to proceed anyway or fix first
- Always provide clear feedback on what failed and why
Commit Message Guidelines
[Rest of the guidelines remain the same...]
Agent Behavior Notes
- Dynamic validation: Adapt to project type and available tools
- LSP integration: Use LSP diagnostics as fallback for code quality checks
- Graceful degradation: If tools missing, still attempt commit with warnings
- Always run and push: Unless user explicitly chooses to fix issues first
- Clear feedback: Explain what validations ran and their results