From 86a17410917f5d6b42edfe49f3a1f19d6ed22d36 Mon Sep 17 00:00:00 2001 From: Zhongwei Li Date: Sun, 30 Nov 2025 08:33:44 +0800 Subject: [PATCH] Initial commit --- .claude-plugin/plugin.json | 18 ++++++++++ README.md | 3 ++ agents/code-reviewer.md | 48 ++++++++++++++++++++++++++ agents/test-generator.md | 50 +++++++++++++++++++++++++++ commands/clean_gone.md | 52 ++++++++++++++++++++++++++++ commands/commit-push-pr.md | 20 +++++++++++ commands/commit.md | 17 ++++++++++ hooks/hooks.json | 14 ++++++++ hooks/validate.sh | 49 +++++++++++++++++++++++++++ plugin.lock.json | 69 ++++++++++++++++++++++++++++++++++++++ 10 files changed, 340 insertions(+) create mode 100644 .claude-plugin/plugin.json create mode 100644 README.md create mode 100644 agents/code-reviewer.md create mode 100644 agents/test-generator.md create mode 100644 commands/clean_gone.md create mode 100644 commands/commit-push-pr.md create mode 100644 commands/commit.md create mode 100644 hooks/hooks.json create mode 100755 hooks/validate.sh create mode 100644 plugin.lock.json diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json new file mode 100644 index 0000000..b410ef8 --- /dev/null +++ b/.claude-plugin/plugin.json @@ -0,0 +1,18 @@ +{ + "name": "example-full-featured", + "description": "Full-featured productivity plugin with Git workflow automation, code review agents, test generation, validation hooks, and example MCP server", + "version": "1.0.0", + "author": { + "name": "ando", + "email": "ando@kivilaid.ee" + }, + "agents": [ + "./agents" + ], + "commands": [ + "./commands" + ], + "hooks": [ + "./hooks" + ] +} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..b30c6a7 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# example-full-featured + +Full-featured productivity plugin with Git workflow automation, code review agents, test generation, validation hooks, and example MCP server diff --git a/agents/code-reviewer.md b/agents/code-reviewer.md new file mode 100644 index 0000000..3aa4b35 --- /dev/null +++ b/agents/code-reviewer.md @@ -0,0 +1,48 @@ +# Code Reviewer Agent + +You are a thorough code review specialist focused on code quality, best practices, and maintainability. + +## Your responsibilities + +When reviewing code, analyze: + +1. **Code Quality** + - Readability and clarity + - Proper naming conventions + - Code organization and structure + - Consistent formatting + +2. **Best Practices** + - Language-specific idioms + - Design patterns usage + - DRY principle adherence + - SOLID principles + +3. **Potential Issues** + - Logic errors + - Edge cases handling + - Error handling + - Resource management + +4. **Security Concerns** + - Input validation + - SQL injection risks + - XSS vulnerabilities + - Authentication/authorization issues + +5. **Performance** + - Algorithm efficiency + - Memory usage + - Unnecessary computations + - Database query optimization + +## Output format + +Provide your review in this structure: +- **Summary**: Brief overview of the code +- **Strengths**: What's done well +- **Issues**: Specific problems found (categorized by severity: Critical, Major, Minor) +- **Suggestions**: Concrete improvement recommendations +- **Code Examples**: Show better alternatives when applicable + +Be constructive, specific, and provide actionable feedback. diff --git a/agents/test-generator.md b/agents/test-generator.md new file mode 100644 index 0000000..304a2c2 --- /dev/null +++ b/agents/test-generator.md @@ -0,0 +1,50 @@ +# Test Generator Agent + +You are an expert at creating comprehensive, maintainable test suites. + +## Your responsibilities + +When generating tests: + +1. **Test Coverage** + - Happy path scenarios + - Edge cases + - Error conditions + - Boundary conditions + +2. **Test Quality** + - Clear test names that describe what's being tested + - Arrange-Act-Assert pattern + - One assertion focus per test + - Proper setup and teardown + +3. **Test Types** + - Unit tests for individual functions/methods + - Integration tests for component interactions + - End-to-end tests for critical user flows + +4. **Best Practices** + - Use appropriate mocking/stubbing + - Avoid test interdependencies + - Make tests deterministic + - Keep tests fast and focused + +## Supported frameworks + +Adapt your test generation to the project's testing framework: +- JavaScript/TypeScript: Jest, Vitest, Mocha, Jasmine +- Python: pytest, unittest +- Java: JUnit, TestNG +- Go: testing package +- Ruby: RSpec, Minitest + +## Output format + +Generate tests with: +- Clear test descriptions +- Comprehensive coverage +- Helpful comments explaining complex scenarios +- Proper assertions +- Mock/stub setup when needed + +Organize tests logically and ensure they're maintainable. diff --git a/commands/clean_gone.md b/commands/clean_gone.md new file mode 100644 index 0000000..092b2d6 --- /dev/null +++ b/commands/clean_gone.md @@ -0,0 +1,52 @@ +--- +description: Cleans up all git branches marked as [gone] (branches that have been deleted on the remote but still exist locally), including removing associated worktrees. +--- + +## Your Task + +You need to execute the following bash commands to clean up stale local branches that have been deleted from the remote repository. + +## Commands to Execute + +1. **First, list branches to identify any with [gone] status** + Execute this command: + ```bash + git branch -v + ``` + + Note: Branches with a '+' prefix have associated worktrees and must have their worktrees removed before deletion. + +2. **Next, identify worktrees that need to be removed for [gone] branches** + Execute this command: + ```bash + git worktree list + ``` + +3. **Finally, remove worktrees and delete [gone] branches (handles both regular and worktree branches)** + Execute this command: + ```bash + # Process all [gone] branches, removing '+' prefix if present + git branch -v | grep '\[gone\]' | sed 's/^[+* ]//' | awk '{print $1}' | while read branch; do + echo "Processing branch: $branch" + # Find and remove worktree if it exists + worktree=$(git worktree list | grep "\\[$branch\\]" | awk '{print $1}') + if [ ! -z "$worktree" ] && [ "$worktree" != "$(git rev-parse --show-toplevel)" ]; then + echo " Removing worktree: $worktree" + git worktree remove --force "$worktree" + fi + # Delete the branch + echo " Deleting branch: $branch" + git branch -D "$branch" + done + ``` + +## Expected Behavior + +After executing these commands, you will: + +- See a list of all local branches with their status +- Identify and remove any worktrees associated with [gone] branches +- Delete all branches marked as [gone] +- Provide feedback on which worktrees and branches were removed + +If no branches are marked as [gone], you should inform the user that no cleanup is necessary. diff --git a/commands/commit-push-pr.md b/commands/commit-push-pr.md new file mode 100644 index 0000000..5ebdd02 --- /dev/null +++ b/commands/commit-push-pr.md @@ -0,0 +1,20 @@ +--- +allowed-tools: Bash(git checkout --branch:*), Bash(git add:*), Bash(git status:*), Bash(git push:*), Bash(git commit:*), Bash(gh pr create:*) +description: Commit, push, and open a PR +--- + +## Context + +- Current git status: !`git status` +- Current git diff (staged and unstaged changes): !`git diff HEAD` +- Current branch: !`git branch --show-current` + +## Your task + +Based on the above changes: + +1. Create a new branch if on main +2. Create a single commit with an appropriate message +3. Push the branch to origin +4. Create a pull request using `gh pr create` +5. You have the capability to call multiple tools in a single response. You MUST do all of the above in a single message. Do not use any other tools or do anything else. Do not send any other text or messages besides these tool calls. diff --git a/commands/commit.md b/commands/commit.md new file mode 100644 index 0000000..31ef079 --- /dev/null +++ b/commands/commit.md @@ -0,0 +1,17 @@ +--- +allowed-tools: Bash(git add:*), Bash(git status:*), Bash(git commit:*) +description: Create a git commit +--- + +## Context + +- Current git status: !`git status` +- Current git diff (staged and unstaged changes): !`git diff HEAD` +- Current branch: !`git branch --show-current` +- Recent commits: !`git log --oneline -10` + +## Your task + +Based on the above changes, create a single git commit. + +You have the capability to call multiple tools in a single response. Stage and create the commit using a single message. Do not use any other tools or do anything else. Do not send any other text or messages besides these tool calls. diff --git a/hooks/hooks.json b/hooks/hooks.json new file mode 100644 index 0000000..aa23ca1 --- /dev/null +++ b/hooks/hooks.json @@ -0,0 +1,14 @@ +{ + "PostToolUse": [ + { + "matcher": "Write|Edit", + "hooks": [ + { + "type": "command", + "command": "${CLAUDE_PLUGIN_ROOT}/hooks/validate.sh", + "args": ["{{file_path}}"] + } + ] + } + ] +} diff --git a/hooks/validate.sh b/hooks/validate.sh new file mode 100755 index 0000000..2ee0d23 --- /dev/null +++ b/hooks/validate.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +# Example validation hook that runs after Write/Edit operations +# This demonstrates how to validate file changes + +FILE_PATH="$1" + +echo "Validating file: $FILE_PATH" + +# Check if file exists +if [ ! -f "$FILE_PATH" ]; then + echo "Warning: File not found: $FILE_PATH" + exit 0 +fi + +# Get file extension +EXT="${FILE_PATH##*.}" + +# Perform basic validation based on file type +case "$EXT" in + json) + echo "Checking JSON syntax..." + if command -v jq &> /dev/null; then + if jq empty "$FILE_PATH" 2>/dev/null; then + echo "✓ JSON validation passed" + else + echo "✗ JSON validation failed" + exit 1 + fi + else + echo "ℹ jq not installed, skipping JSON validation" + fi + ;; + sh) + echo "Checking shell script syntax..." + if bash -n "$FILE_PATH" 2>/dev/null; then + echo "✓ Shell script syntax valid" + else + echo "✗ Shell script syntax error" + exit 1 + fi + ;; + *) + echo "ℹ No specific validation for .$EXT files" + ;; +esac + +echo "Validation complete" +exit 0 diff --git a/plugin.lock.json b/plugin.lock.json new file mode 100644 index 0000000..2e10c77 --- /dev/null +++ b/plugin.lock.json @@ -0,0 +1,69 @@ +{ + "$schema": "internal://schemas/plugin.lock.v1.json", + "pluginId": "gh:kivilaid/plugin-marketplace:plugins/example-full-featured", + "normalized": { + "repo": null, + "ref": "refs/tags/v20251128.0", + "commit": "825748d4933ddc06a4e53d6b8cdfc9edbce17317", + "treeHash": "8017336b101674247b8e2aff549affd2c6054be49d67f0d0779e8d88cb0d02b3", + "generatedAt": "2025-11-28T10:19:32.468245Z", + "toolVersion": "publish_plugins.py@0.2.0" + }, + "origin": { + "remote": "git@github.com:zhongweili/42plugin-data.git", + "branch": "master", + "commit": "aa1497ed0949fd50e99e70d6324a29c5b34f9390", + "repoRoot": "/Users/zhongweili/projects/openmind/42plugin-data" + }, + "manifest": { + "name": "example-full-featured", + "description": "Full-featured productivity plugin with Git workflow automation, code review agents, test generation, validation hooks, and example MCP server", + "version": "1.0.0" + }, + "content": { + "files": [ + { + "path": "README.md", + "sha256": "95e892f26b86538c933061087f4b855614eaf2ff792f0d643c2fbb2019f441d6" + }, + { + "path": "agents/code-reviewer.md", + "sha256": "84396fa2f05cc031e332ed0392fa210a15d4ba6cb32758ddeae259ebd32bc34d" + }, + { + "path": "agents/test-generator.md", + "sha256": "43beff78e478253624798660c3d521111c4a332067d095137e1412251609581f" + }, + { + "path": "hooks/validate.sh", + "sha256": "bac0e501e94cf30c4d64bfaeeab7ecb688f6ba2122485ea2e0dca4a83389a751" + }, + { + "path": "hooks/hooks.json", + "sha256": "f19bd0838a3766dd853427b0dbd3cbb9fd9572ee61525a5b01c98a6d59761e64" + }, + { + "path": ".claude-plugin/plugin.json", + "sha256": "00aff05462ed0b6e9b7b084a13eb6cc76d4df503d4f96fcf742015c55f9c65b7" + }, + { + "path": "commands/commit-push-pr.md", + "sha256": "3bc3d171939149cbbef141cbced553dce6ba6f97dac4a764f4ef1e055c35064d" + }, + { + "path": "commands/clean_gone.md", + "sha256": "b066a07addcfb543b54a8286d4cf537b15f5ae87d4597a56999a6c802d860a72" + }, + { + "path": "commands/commit.md", + "sha256": "d1acbc2bf0c50164f48d6bda872de6a343cd9390954ce903c3431c3119e7f8c4" + } + ], + "dirSha256": "8017336b101674247b8e2aff549affd2c6054be49d67f0d0779e8d88cb0d02b3" + }, + "security": { + "scannedAt": null, + "scannerVersion": null, + "flags": [] + } +} \ No newline at end of file