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

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>