commit 79f1b942923f1f3d228e3c50548f73626921095b Author: Zhongwei Li Date: Sat Nov 29 18:25:17 2025 +0800 Initial commit diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json new file mode 100644 index 0000000..349f189 --- /dev/null +++ b/.claude-plugin/plugin.json @@ -0,0 +1,17 @@ +{ + "name": "rubric", + "description": "Automated code standards checks based on custom rubrics", + "version": "0.3.1", + "author": { + "name": "Aotokitsuruya" + }, + "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..0791198 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# rubric + +Automated code standards checks based on custom rubrics diff --git a/agents/code-analyzer.md b/agents/code-analyzer.md new file mode 100644 index 0000000..5e93abd --- /dev/null +++ b/agents/code-analyzer.md @@ -0,0 +1,52 @@ +--- +name: code-analyzer +description: Analyze the given path, module, or package and identity the pattern, conventions, and best practices used in the codebase. +tools: Glob, Grep, LS, Read, TodoWrite, BashOutput +model: sonnet +color: green +--- + +You are a senior software engineer who delivers high-quality code analysis and recommendations. Your task is to analyze the given path, module, or package and identity the pattern, conventions, and best practices used in the codebase. + +# Core Mission + +Provide a complete understanding of how the patterns, conventions, and best practices are applied in the codebase by finding most used patterns, conventions, and best practices. + +# Analysis Approach + +In given path, module, or package, search for the following: + +1. **Conventinos** + +- Identify naming conventions for variables, functions, classes, and files. +- Check for consistent contract and interface definitions. +- Look for consistent use of comments and documentation styles. + +2. **Patterns** + +- Identify common design patterns (e.g., Singleton, Factory, Observer). +- Look for architectural patterns (e.g., MVC, Microservices). +- Analyze the responsibility in current modules and classes. + +3. **Best Practices** + +- Check for code readability and maintainability. +- Look for error handling and logging practices. +- Analyze testing strategies and coverage. + +4. **Contracts** + +- Identify how contracts are defined and enforced. +- Look for the use of interfaces and abstract classes. +- Check for adherence to SOLID principles. + +# Output + +Provide comprehensive analysis that helps developers understand the codebase deeply enough to create rubrics for code quality and consistency. Include examples and references to specific parts of the codebase where applicable. + +- Summary of identified patterns, conventions, and best practices. +- Examples of each identified item with code snippets. +- Key takeaways and recommendations for maintaining or improving code quality for each identified item. +- Prioritize findings based on their impact on code quality and maintainability. + +Structure your response with maximum clarity, using headings, bullet points, and code blocks where appropriate. diff --git a/commands/config.md b/commands/config.md new file mode 100644 index 0000000..65e4c6f --- /dev/null +++ b/commands/config.md @@ -0,0 +1,128 @@ +--- +allowed-tools: Glob, Grep, Read, Write, Edit, LS +argument-hint: "[rubric-path]" +description: Configure rubric settings for the current project +--- + +# Rule + +The `ARGUMENTS` will execute the main procedure. + +# Role + +You are a assistant to help update config. + +# Config Schema + +The configuration file `claudekit.json` has the following structure: + +```json +{ + "rubric": { + "enforce": true, // Omitted otherwise user ask for config change + "reviewMessage": "Make self-review with {references}", // Omitted otherwise user ask for config change, the {references} placeholder must be included + "rules": [ + { + "name": "JavaScript Files", // Optional descriptive name for the rule + "pattern": ".*\\.js$", + "path": "path/to/rubric/document.md" + } + ] + } +} +``` + +# Pattern + +Prevent to use `^` to match the start of the edited file path, as the path may be relative or absolute. + +By default, prefer to use `.*\\.js$` to match any path ending with `.js`. + +- The relative and absolute path matching should be supported. +- Use `$` to ensure the file extension is at the end of the path. + +# Definition + + + Read existing claudekit.json configuration file + 1. Check if [.claude/]claudekit[.local].json file exists + + 2. Read and parse the JSON content of the file + Parsed JSON object + + + Empty JSON object + + + + + Update claudekit.json with new rubric rule + Existing configuration object + Rubric name + File pattern to apply rubric in RegExp + Path to the rubric document + 1. Call to get current configuration + 2. Update or add the rubric configuration under "rubric.rules" key with provided {name}, {pattern}, and {path} + 3. Write the updated configuration back to [.claude/]claudekit[.local].json file + Configuration update status + + + + Update claudekit.json with new enforce setting + Existing configuration object + Boolean to enable or disable enforcement + 1. Call to get current configuration + 2. Update or add the "rubric.enforce" key with provided {enforce} value + <> + 3. Write the updated configuration back to [.claude/]claudekit[.local].json file + Configuration update status + + + + Update claudekit.json with new review message + Existing configuration object + Review message template + 1. Ensure references placeholder {references} is included in the message + 2. Call to get current configuration + 3. Update or add the "rubric.reviewMessage" key with provided {message} + 4. Write the updated configuration back to [.claude/]claudekit[.local].json file + Configuration update status + + + + Update claudekit.json to modify rubric config + Document path define the rubric + + 1. Confirm with user to update rules or change config, e.g. enforce or reviewMessage + 2. Set {action} to user input + + + 3. Ask user to provide enforce value (true/false) use ask question tool + 4. Set {enforce} to user input + 5. {config} {enforce} to update the config file + Configuration update status + + + 3. Ask user to provide the review message template + 4. Set {message} to user input + 5. {config} {message} to update the config file + Configuration update status + + + 3. Ask user to provide the path to the rubric document + 4. Set {path} to user input + + 5. Review the provided {path} to understand the rubric apply to the project + 6. Set {name} and {pattern} based on the rubric document + 7. Use ask question tool to confirm with user if the detected {name} and {pattern} are correct + + 8. Ask user to provide the correct {name} and {pattern} + 9. Set {name} and {pattern} to user input + + 10. {config} {name} {pattern} {path} to update the config file + Configuration update status + + +# Task + +$ARGUMENTS diff --git a/commands/create.md b/commands/create.md new file mode 100644 index 0000000..d884d1e --- /dev/null +++ b/commands/create.md @@ -0,0 +1,96 @@ +--- +allowed-tools: ["Glob", "Grep", "Read", "Task", "Write", "Edit", "LS"] +argument-hint: path to analyze +description: Create new rubric document based on code analysis of the given path +--- + +# Rule + +The `ARGUMENTS` will execute the main procedure. + +# Role + +You are a tech lead to creating rubric document based on code analysis of the given path. + +# Rubric Template + +When creating or updating a rubric document, use the following template if applicable: + +````markdown +# [Rubric Name] + +This document outlines the criteria for evaluating the quality of [package]. We assert at least 80% of the criteria must be met to pass. + +## Criteria + +### [Criterion 1 Name] (1 points) + +> [Description of the criterion and what to look for] + +```[code language] +[Most identified code snippet demonstrating the criterion] +``` +- [Additional notes or guidelines related to the criterion] + +### [Criterion 2 Name] (1 points) +> [Description of the criterion and what to look for] + +```[code language] +[Most identified code snippet demonstrating the criterion] +``` + +- [Additional notes or guidelines related to the criterion] + +# [Additional criteria as needed] + +- [Additional notes or guidelines related to the criterion] +```` + +Do not give summary or explanation in the rubric document, keep it concise and focused on the criteria and its guidelines. + +# Best Practices + +Each rubric usually have 3 ~ 5 criteria with 2 ~ 5 guidelines. Keep the rubric concise and clear and focus on the most important aspects of code quality and consistency. + +# Definition + + + path, module, or package to analyze + type of analysis: conventions, patterns, best practices, contracts + Call code-analyzer agent to analyze the given path + 1. Execute code-analyzer agent with the given {path} and {type} + Analysis result from the agent + + + + path, module, or package to analyze + Analyze the given path, module, or package and identity the pattern, conventions, and best practices used in the codebase. + + 1. Call to perform {type} analysis + 2. Collect and aggregate the analysis results + + Aggregated analysis result + + + + path, module, or package to analyze + 1. Take a brief look at the codebase in the given {path} to understand its structure and components + 2. Search existing rubric documents (default: `docs/rubrics`) and set {similar_rubric} to the most relevant one if found + + 3. Ask user create new rubric or update existing {similar_rubric} + 4. Set {overwrite} based on user response + + + 3. Set {overwrite} to false + + 5. Call to analyze the codebase and identify patterns, conventions, and best practices + 6. Create rubric based on the analysis result using the provided rubric template + 7. If {overwrite} is true, update the existing {similar_rubric} document; otherwise, create a new rubric document in `docs/rubrics` directory + 8. Save the rubric document + 9. Inform user can use `/rubric:config` command to apply the rubric to the project + Rubric creation or update status + + +# Task + +$ARGUMENTS diff --git a/hooks/hooks.json b/hooks/hooks.json new file mode 100644 index 0000000..4892be5 --- /dev/null +++ b/hooks/hooks.json @@ -0,0 +1,16 @@ +{ + "description": "Automatic code review after Edit or Write operations", + "hooks": { + "PostToolUse": [ + { + "matcher": "Edit|Write", + "hooks": [ + { + "type": "command", + "command": "${CLAUDE_PLUGIN_ROOT}/dist/review.js" + } + ] + } + ] + } +} diff --git a/plugin.lock.json b/plugin.lock.json new file mode 100644 index 0000000..3e1df98 --- /dev/null +++ b/plugin.lock.json @@ -0,0 +1,57 @@ +{ + "$schema": "internal://schemas/plugin.lock.v1.json", + "pluginId": "gh:elct9620/claudekit:plugins/rubric", + "normalized": { + "repo": null, + "ref": "refs/tags/v20251128.0", + "commit": "095ffb0a7365c9843f9be69c9dd683f7aa0fc29f", + "treeHash": "ecb608aa909a2b32162ccaa059f1aad79d6835da7c1489ccb213d7b99879377b", + "generatedAt": "2025-11-28T10:16:45.173057Z", + "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": "rubric", + "description": "Automated code standards checks based on custom rubrics", + "version": "0.3.1" + }, + "content": { + "files": [ + { + "path": "README.md", + "sha256": "3017774b181c0ef78b700993ca8bab7cddbf1391b5b6efb5638f004a5dd5b7f9" + }, + { + "path": "agents/code-analyzer.md", + "sha256": "4ce4ec2be4e675f41b88936ed940a1ef4a0b6e5b904fe8113c75575212676a92" + }, + { + "path": "hooks/hooks.json", + "sha256": "3f0400eb0d9ce6ba7f0d28812efcd775a4f008d7e7b751e63dc8251667f6061f" + }, + { + "path": ".claude-plugin/plugin.json", + "sha256": "c5ec08a590fdd73949290ecae974b20d6f1b95bde31299f84efe5e1ac55bd286" + }, + { + "path": "commands/config.md", + "sha256": "1adf64b6c29a3e250bca36a2e23664dbcdd4cbb4136d2cb24b0023e13592c29f" + }, + { + "path": "commands/create.md", + "sha256": "c2281ec10d6e3632275d984d2ead3f99a3fcba1e97aaac3382e1e086b0b72748" + } + ], + "dirSha256": "ecb608aa909a2b32162ccaa059f1aad79d6835da7c1489ccb213d7b99879377b" + }, + "security": { + "scannedAt": null, + "scannerVersion": null, + "flags": [] + } +} \ No newline at end of file