Initial commit

This commit is contained in:
Zhongwei Li
2025-11-29 18:25:17 +08:00
commit 79f1b94292
7 changed files with 369 additions and 0 deletions

View File

@@ -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"
]
}

3
README.md Normal file
View File

@@ -0,0 +1,3 @@
# rubric
Automated code standards checks based on custom rubrics

52
agents/code-analyzer.md Normal file
View File

@@ -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.

128
commands/config.md Normal file
View File

@@ -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 `<execute>ARGUMENTS</execute>` 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
<function name="read_config">
<description>Read existing claudekit.json configuration file</description>
<step>1. Check if [.claude/]claudekit[.local].json file exists</step>
<condition if="file exists">
<step>2. Read and parse the JSON content of the file</step>
<return>Parsed JSON object</return>
</condition>
<condition if="file does not exist">
<return>Empty JSON object</return>
</condition>
</function>
<function name="apply_rule">
<description>Update claudekit.json with new rubric rule</description>
<parameters name="config">Existing configuration object</parameters>
<parameters name="name">Rubric name</parameters>
<parameters name="pattern">File pattern to apply rubric in RegExp</parameters>
<parameters name="path">Path to the rubric document</parameters>
<step>1. Call <execute name="read_config" /> to get current configuration</step>
<step>2. Update or add the rubric configuration under "rubric.rules" key with provided {name}, {pattern}, and {path}</step>
<step>3. Write the updated configuration back to [.claude/]claudekit[.local].json file</step>
<return>Configuration update status</return>
</function>
<function name="apply_enforce">
<description>Update claudekit.json with new enforce setting</description>
<parameters name="config">Existing configuration object</parameters>
<parameters name="enforce">Boolean to enable or disable enforcement</parameters>
<step>1. Call <execute name="read_config" /> to get current configuration</step>
<step>2. Update or add the "rubric.enforce" key with provided {enforce} value</step>
<>
<step>3. Write the updated configuration back to [.claude/]claudekit[.local].json file</step>
<return>Configuration update status</return>
</function>
<function name="apply_review_message">
<description>Update claudekit.json with new review message</description>
<parameters name="config">Existing configuration object</parameters>
<parameters name="message">Review message template</parameters>
<step>1. Ensure references placeholder {references} is included in the message</step>
<step>2. Call <execute name="read_config" /> to get current configuration</step>
<step>3. Update or add the "rubric.reviewMessage" key with provided {message}</step>
<step>4. Write the updated configuration back to [.claude/]claudekit[.local].json file</step>
<return>Configuration update status</return>
</function>
<procedure name="main">
<description>Update claudekit.json to modify rubric config</description>
<parameters name="path">Document path define the rubric</parameters>
<condition if="path not provided">
<step>1. Confirm with user to update rules or change config, e.g. enforce or reviewMessage</step>
<step>2. Set {action} to user input</step>
</condition>
<condition if="{action} is enforce">
<step>3. Ask user to provide enforce value (true/false) use ask question tool</step>
<step>4. Set {enforce} to user input</step>
<step>5. <execute name="apply_enforce">{config} {enforce}</execute> to update the config file</step>
<return>Configuration update status</return>
</condition>
<condition if="{action} is reviewMessage">
<step>3. Ask user to provide the review message template</step>
<step>4. Set {message} to user input</step>
<step>5. <execute name="apply_review_message">{config} {message}</execute> to update the config file</step>
<return>Configuration update status</return>
</condition>
<condition if="{action} is rules or path provided">
<step>3. Ask user to provide the path to the rubric document</step>
<step>4. Set {path} to user input</step>
</condition>
<step>5. Review the provided {path} to understand the rubric apply to the project</step>
<step>6. Set {name} and {pattern} based on the rubric document</step>
<step>7. Use ask question tool to confirm with user if the detected {name} and {pattern} are correct</step>
<condition if="user deny the detected name or pattern">
<step>8. Ask user to provide the correct {name} and {pattern}</step>
<step>9. Set {name} and {pattern} to user input</step>
</condition>
<step>10. <execute name="apply_config">{config} {name} {pattern} {path}</execute> to update the config file</step>
<return>Configuration update status</return>
</procedure>
# Task
<execute name="main">$ARGUMENTS</execute>

96
commands/create.md Normal file
View File

@@ -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 `<execute>ARGUMENTS</execute>` 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
<function name="call_analyze_agent">
<parameters name="path">path, module, or package to analyze</parameters>
<parameters name="type">type of analysis: conventions, patterns, best practices, contracts</parameters>
<description>Call code-analyzer agent to analyze the given path</description>
<step>1. Execute code-analyzer agent with the given {path} and {type}</step>
<return>Analysis result from the agent</return>
</function>
<procedure name="code_analyzer">
<parameters name="path">path, module, or package to analyze</parameters>
<description>Analyze the given path, module, or package and identity the pattern, conventions, and best practices used in the codebase.</description>
<loop for="type in ['conventions', 'patterns', 'best practices', 'contracts']" parallel="true">
<step>1. Call <execute name="call_analyze_agent" path="{path}" type="{type}" /> to perform {type} analysis</step>
<step>2. Collect and aggregate the analysis results</step>
</loop>
<return>Aggregated analysis result</return>
</procedure>
<procedure name="main">
<parameters name="path">path, module, or package to analyze</parameters>
<step>1. Take a brief look at the codebase in the given {path} to understand its structure and components</step>
<step>2. Search existing rubric documents (default: `docs/rubrics`) and set {similar_rubric} to the most relevant one if found</step>
<condition if="similar_rubric found">
<step>3. Ask user create new rubric or update existing {similar_rubric}</step>
<step>4. Set {overwrite} based on user response</step>
</condition>
<condition if="similar_rubric not found">
<step>3. Set {overwrite} to false</step>
</condition>
<step>5. Call <execute name="code_analyzer" path="{path}" /> to analyze the codebase and identify patterns, conventions, and best practices</step>
<step>6. Create rubric based on the analysis result using the provided rubric template</step>
<step>7. If {overwrite} is true, update the existing {similar_rubric} document; otherwise, create a new rubric document in `docs/rubrics` directory</step>
<step>8. Save the rubric document</step>
<step>9. Inform user can use `/rubric:config` command to apply the rubric to the project</step>
<return>Rubric creation or update status</return>
</procedure>
# Task
<execute name="main">$ARGUMENTS</execute>

16
hooks/hooks.json Normal file
View File

@@ -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"
}
]
}
]
}
}

57
plugin.lock.json Normal file
View File

@@ -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": []
}
}