install
source · Clone the upstream repo
git clone https://github.com/jieni777/opencode-config-backup
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/jieni777/opencode-config-backup "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/commit" ~/.claude/skills/jieni777-opencode-config-backup-commit && rm -rf "$T"
manifest:
skills/commit/SKILL.mdsource content
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
ormypy .
if available, else use LSP diagnosticsruff check . - Ruby (.rb): Run
if available, else use LSP diagnosticsrubocop - JavaScript/TypeScript (.js, .ts, .tsx): Run
oreslint .
if available, else use LSP diagnosticstsc --noEmit - Go (.go): Run
orgo vet ./...
if available, else use LSP diagnosticsgolangci-lint run - Rust (.rs): Run
orcargo check
if available, else use LSP diagnosticscargo clippy - Markdown (.md): Check for basic formatting issues (long lines, etc.) or use
if availablemarkdownlint - Other text files: Use LSP diagnostics if LSP server available
- Python (.py): Run
- For all code files, run
to check for errors/warningslsp_diagnostics - If any validation fails, ask user if they want to proceed anyway or fix issues first
- Analyze staged files with
-
Analyze git status:
- Run
to check for changesgit status --porcelain - If no files are staged, run
to stage all modified filesgit add . - If files are already staged, proceed with only those files
- Run
-
Analyze the changes:
- Run
to see what will be committedgit diff --cached - 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:
→ Python validation.py
→ Ruby validation.rb
,.js
,.ts
→ JavaScript/TypeScript validation.tsx
→ Go validation.go
→ Rust validation.rs
→ Markdown validation.md- 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
on each changed filelsp_diagnostics - 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
if available, else basic checksmarkdownlint
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