From 0d567cfdda2c6e7f5ce62522278908310a86e942 Mon Sep 17 00:00:00 2001 From: Zhongwei Li Date: Sun, 30 Nov 2025 08:30:57 +0800 Subject: [PATCH] Initial commit --- .claude-plugin/plugin.json | 11 ++ README.md | 3 + commands/setup-claude-md.md | 116 ++++++++++++++++ commands/setup-code-quality.md | 168 +++++++++++++++++++++++ commands/setup-commits.md | 51 +++++++ commands/setup-updates.md | 237 +++++++++++++++++++++++++++++++++ plugin.lock.json | 57 ++++++++ 7 files changed, 643 insertions(+) create mode 100644 .claude-plugin/plugin.json create mode 100644 README.md create mode 100644 commands/setup-claude-md.md create mode 100644 commands/setup-code-quality.md create mode 100644 commands/setup-commits.md create mode 100644 commands/setup-updates.md create mode 100644 plugin.lock.json diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json new file mode 100644 index 0000000..7e3d619 --- /dev/null +++ b/.claude-plugin/plugin.json @@ -0,0 +1,11 @@ +{ + "name": "minimal-claude", + "description": "Auto-configure code quality tools and generate custom /fix command for parallel agent-based fixing", + "version": "1.4.0", + "author": { + "name": "kenkai" + }, + "commands": [ + "./commands" + ] +} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..5256ac1 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# minimal-claude + +Auto-configure code quality tools and generate custom /fix command for parallel agent-based fixing diff --git a/commands/setup-claude-md.md b/commands/setup-claude-md.md new file mode 100644 index 0000000..6985ec2 --- /dev/null +++ b/commands/setup-claude-md.md @@ -0,0 +1,116 @@ +--- +name: setup-claude-md +description: Generate or update a minimal CLAUDE.md with project guidelines and structure +--- + +Generate or update a minimal CLAUDE.md with project structure, guidelines, and quality checks. + +## Step 1: Check if CLAUDE.md Exists + +If `CLAUDE.md` exists: +- Read the existing file +- Preserve custom sections the user may have added +- Update the structure, quality checks, and organization rules + +If `CLAUDE.md` does NOT exist: +- Create a new one from scratch + +## Step 2: Analyze Project (Use Explore Agents in Parallel) + +Spawn parallel Explore agents to understand the codebase: + +1. **Project Purpose Agent**: Analyze README, package.json description, main files to understand what the project does +2. **Directory Structure Agent**: Map out the folder structure and what each folder contains +3. **Tech Stack Agent**: Identify languages, frameworks, tools, dependencies + +Wait for all agents to complete, then synthesize the information. + +## Step 3: Detect Project Type & Commands + +Check for config files: +- `package.json` → JavaScript/TypeScript (extract lint, typecheck, server scripts) +- `pyproject.toml` or `requirements.txt` → Python +- `go.mod` → Go +- `Cargo.toml` → Rust + +Extract: +- Linting commands +- Typechecking commands +- Server start command (if applicable) + +## Step 4: Generate Project Tree + +Create a concise tree structure showing key directories and files with brief descriptions. + +Example format: +``` +src/ + ├── api/ # API endpoints and routes + ├── components/ # Reusable UI components + ├── utils/ # Helper functions and utilities + ├── types/ # TypeScript type definitions + └── main.ts # Application entry point +``` + +## Step 5: Generate or Update CLAUDE.md + +Create `CLAUDE.md` with this structure: + +```markdown +# [Project Name] + +[Brief 1-2 sentence description of what this project does] + +## Project Structure + +[INSERT TREE HERE] + +## Organization Rules + +**Keep code organized and modularized:** +- API routes → `/api` folder, one file per route/resource +- Components → `/components`, one component per file +- Utilities → `/utils`, grouped by functionality +- Types/Interfaces → `/types` or co-located with usage +- Tests → Next to the code they test or in `/tests` + +**Modularity principles:** +- Single responsibility per file +- Clear, descriptive file names +- Group related functionality together +- Avoid monolithic files + +## Code Quality - Zero Tolerance + +After editing ANY file, run: + +```bash +[EXACT COMMANDS FROM PROJECT] +``` + +Fix ALL errors/warnings before continuing. + +[IF SERVER EXISTS:] +If changes require server restart (not hot-reloadable): +1. Restart server: `[SERVER COMMAND]` +2. Read server output/logs +3. Fix ALL warnings/errors before continuing +``` + +**Keep total file under 100 lines.** + +## Step 6: Preserve Custom Sections + +If updating an existing CLAUDE.md: +- Keep any custom sections the user added +- Update the generated sections (Project Structure, Quality Checks) +- Merge carefully without losing user content + +## Step 7: Confirm Completion + +Tell the user: +- ✅ CLAUDE.md [created/updated] +- 📋 Project: [brief description] +- 🗂️ Structure mapped with [X] directories +- 📐 Organization rules enforced +- 🎯 Zero-tolerance quality checks active diff --git a/commands/setup-code-quality.md b/commands/setup-code-quality.md new file mode 100644 index 0000000..f5311e5 --- /dev/null +++ b/commands/setup-code-quality.md @@ -0,0 +1,168 @@ +--- +name: setup-code-quality +description: Detect project tools and generate a /check command for linting and typechecking +--- + +You are setting up a project for automated code quality checks. Follow these steps carefully: + +## Step 1: Detect Project Type + +Check for these files in the current directory to determine the project type: +- `package.json` → JavaScript/TypeScript (Node.js) +- `pyproject.toml` or `requirements.txt` or `setup.py` → Python +- `go.mod` → Go +- `Cargo.toml` → Rust +- `composer.json` → PHP +- `build.gradle` or `pom.xml` → Java + +Read the relevant config file to understand the project structure. + +## Step 2: Check Existing Tools + +Based on the project type, check if these tools are already configured: + +### JavaScript/TypeScript: +- Check `package.json` for: `eslint`, `prettier`, `typescript`, `@typescript-eslint/*` +- Check for config files: `.eslintrc.*`, `.prettierrc.*`, `tsconfig.json` +- Check `package.json` scripts for: `lint`, `typecheck`, `type-check`, or `tsc` + +### Python: +- Check for: `mypy`, `pylint`, `black`, `ruff`, `flake8` in dependencies +- Check for config files: `mypy.ini`, `.pylintrc`, `pyproject.toml` +- Look for linting/type checking configurations + +### Go: +- Check for: `golint`, `gofmt`, `staticcheck` +- Go has built-in tools, check if project uses them + +### Rust: +- Check for: `clippy`, `rustfmt` (built-in to Rust toolchain) +- Check `Cargo.toml` for workspace configuration + +## Step 3: Install Missing Tools (if needed) + +If tools are missing, install them based on the project type: + +### JavaScript/TypeScript: +```bash +# Detect package manager (npm, yarn, pnpm, bun) +# Install missing tools, e.g.: +npm install --save-dev eslint prettier typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin + +# Add scripts to package.json if missing: +# "lint": "eslint ." +# "typecheck": "tsc --noEmit" +``` + +### Python: +```bash +pip install mypy pylint black ruff +# or add to requirements-dev.txt / pyproject.toml +``` + +### Go: +```bash +go install golang.org/x/lint/golint@latest +go install honnef.co/go/tools/cmd/staticcheck@latest +``` + +### Rust: +```bash +rustup component add clippy rustfmt +``` + +**IMPORTANT**: Always check if tools exist first. Only install if missing. + +## Step 4: Generate /fix Command + +Create a file at `.claude/commands/fix.md` with the following structure: + +```markdown +--- +name: fix +description: Run typechecking and linting, then spawn parallel agents to fix all issues +--- + +# Project Code Quality Check + +This command runs all linting and typechecking tools for this project, collects errors, groups them by domain, and spawns parallel agents to fix them. + +## Step 1: Run Linting and Typechecking + +Run the appropriate commands for this project: + +[INSERT PROJECT-SPECIFIC COMMANDS HERE] + +## Step 2: Collect and Parse Errors + +Parse the output from the linting and typechecking commands. Group errors by domain: +- **Type errors**: Issues from TypeScript, mypy, etc. +- **Lint errors**: Issues from eslint, pylint, ruff, clippy, etc. +- **Format errors**: Issues from prettier, black, rustfmt, gofmt + +Create a list of all files with issues and the specific problems in each file. + +## Step 3: Spawn Parallel Agents + +For each domain that has issues, spawn an agent in parallel using the Task tool: + +**IMPORTANT**: Use a SINGLE response with MULTIPLE Task tool calls to run agents in parallel. + +Example: +- Spawn a "type-fixer" agent for type errors +- Spawn a "lint-fixer" agent for lint errors +- Spawn a "format-fixer" agent for formatting errors + +Each agent should: +1. Receive the list of files and specific errors in their domain +2. Fix all errors in their domain +3. Run the relevant check command to verify fixes +4. Report completion + +## Step 4: Verify All Fixes + +After all agents complete, run the full check again to ensure all issues are resolved. +``` + +**Replace `[INSERT PROJECT-SPECIFIC COMMANDS HERE]` with the actual commands for the detected project type.** + +### JavaScript/TypeScript Example: +```bash +npm run lint +npm run typecheck +``` + +### Python Example: +```bash +mypy . +pylint src/ +black --check . +``` + +### Go Example: +```bash +go vet ./... +staticcheck ./... +gofmt -l . +``` + +### Rust Example: +```bash +cargo clippy -- -D warnings +cargo fmt -- --check +``` + +## Step 5: Confirm Completion + +After generating the `/fix` command, inform the user: +1. What project type was detected +2. Which tools were already present +3. Which tools were installed (if any) +4. That the `/fix` command has been created at `.claude/commands/fix.md` +5. How to use it: "Run `/fix` to lint, typecheck, and auto-fix all issues" + +**Important Notes**: +- Always create the `.claude/commands/` directory if it doesn't exist +- Ensure the YAML frontmatter includes both `name` and `description` +- The generated `/fix` command must spawn agents in parallel (single response, multiple Task tool calls) +- Tailor the commands to what's actually available in the project diff --git a/commands/setup-commits.md b/commands/setup-commits.md new file mode 100644 index 0000000..09794b3 --- /dev/null +++ b/commands/setup-commits.md @@ -0,0 +1,51 @@ +--- +name: setup-commits +description: Generate a /commit command that runs checks, then commits with AI-generated messages +--- + +Generate a minimal `/commit` command that enforces quality checks before committing. + +## Step 1: Detect Project and Extract Commands + +Check for config files: +- `package.json` → Extract `lint`, `typecheck` scripts +- `pyproject.toml` → Use `mypy`, `pylint` +- `go.mod` → Use `go vet ./...`, `gofmt -l .` +- `Cargo.toml` → Use `cargo clippy`, `cargo fmt --check` + +## Step 2: Generate /commit Command + +Create `.claude/commands/commit.md`: + +```markdown +--- +name: commit +description: Run checks, commit with AI message, and push +--- + +1. Run quality checks: + ```bash + [PROJECT COMMANDS] + ``` + Fix ALL errors before continuing. + +2. Review changes: `git status` and `git diff` + +3. Generate commit message: + - Start with verb (Add/Update/Fix/Remove/Refactor) + - Be specific and concise + - One line preferred + +4. Commit and push: + ```bash + git add -A + git commit -m "your generated message" + git push + ``` +``` + +**Keep it under 20 lines.** + +## Step 3: Confirm + +Tell user: ✅ `/commit` created. Quality checks + AI commits + auto-push enabled. diff --git a/commands/setup-updates.md b/commands/setup-updates.md new file mode 100644 index 0000000..4149942 --- /dev/null +++ b/commands/setup-updates.md @@ -0,0 +1,237 @@ +--- +name: setup-updates +description: Generate a /update-app command for dependency updates and deprecation fixes +--- + +Generate a minimal `/update-app` command that updates dependencies and fixes deprecations. + +## Step 1: Detect Project Type + +Check for config files: +- `package.json` → JavaScript/TypeScript (npm/yarn/pnpm/bun) +- `pyproject.toml` or `requirements.txt` → Python (pip/poetry) +- `go.mod` → Go +- `Cargo.toml` → Rust +- `composer.json` → PHP + +## Step 2: Detect Package Manager + +**For JavaScript/TypeScript**: Check for lock files: +- `package-lock.json` → npm +- `yarn.lock` → yarn +- `pnpm-lock.yaml` → pnpm +- `bun.lockb` → bun + +**For Python**: Check for: +- `poetry.lock` → poetry +- Otherwise → pip + +## Step 3: Generate /update-app Command + +Create `.claude/commands/update-app.md`: + +```markdown +--- +name: update-app +description: Update dependencies, fix deprecations and warnings +--- + +# Dependency Update & Deprecation Fix + +## Step 1: Check for Updates + +[INSERT CHECK COMMAND] + +## Step 2: Update Dependencies + +[INSERT UPDATE COMMAND] + +## Step 3: Check for Deprecations & Warnings + +Run installation and check output: +[INSERT INSTALL COMMAND] + +Read ALL output carefully. Look for: +- Deprecation warnings +- Security vulnerabilities +- Peer dependency warnings +- Breaking changes + +## Step 4: Fix Issues + +For each warning/deprecation: +1. Research the recommended replacement or fix +2. Update code/dependencies accordingly +3. Re-run installation +4. Verify no warnings remain + +## Step 5: Run Quality Checks + +[INSERT QUALITY CHECK COMMANDS] + +Fix all errors before completing. + +## Step 6: Verify Clean Install + +Ensure a fresh install works: +1. Delete dependency folders/caches +2. Run clean install +3. Verify ZERO warnings/errors +4. Confirm all dependencies resolve correctly +``` + +## Step 4: Customize by Project Type + +**Replace placeholders with actual commands:** + +### JavaScript/TypeScript (npm): +```markdown +## Step 1: Check for Updates +```bash +npm outdated +``` + +## Step 2: Update Dependencies +```bash +npm update +npm audit fix +``` + +## Step 3: Check for Deprecations & Warnings +```bash +rm -rf node_modules package-lock.json +npm install +``` + +## Step 5: Run Quality Checks +```bash +npm run lint +npm run typecheck +``` + +## Step 6: Verify Clean Install +```bash +rm -rf node_modules package-lock.json +npm install +``` +``` + +### JavaScript/TypeScript (yarn): +```markdown +## Step 1: Check for Updates +```bash +yarn outdated +``` + +## Step 2: Update Dependencies +```bash +yarn upgrade +yarn audit +``` + +## Step 3: Check for Deprecations & Warnings +```bash +rm -rf node_modules yarn.lock +yarn install +``` +``` + +### Python (pip): +```markdown +## Step 1: Check for Updates +```bash +pip list --outdated +``` + +## Step 2: Update Dependencies +```bash +pip install --upgrade -r requirements.txt +``` + +## Step 3: Check for Deprecations & Warnings +```bash +pip install -r requirements.txt +``` + +## Step 5: Run Quality Checks +```bash +mypy . +pylint src/ +``` +``` + +### Python (poetry): +```markdown +## Step 1: Check for Updates +```bash +poetry show --outdated +``` + +## Step 2: Update Dependencies +```bash +poetry update +``` + +## Step 3: Check for Deprecations & Warnings +```bash +poetry install +``` +``` + +### Go: +```markdown +## Step 1: Check for Updates +```bash +go list -u -m all +``` + +## Step 2: Update Dependencies +```bash +go get -u ./... +go mod tidy +``` + +## Step 3: Check for Deprecations & Warnings +```bash +go mod download +``` + +## Step 5: Run Quality Checks +```bash +go vet ./... +gofmt -l . +``` +``` + +### Rust: +```markdown +## Step 1: Check for Updates +```bash +cargo outdated +``` + +## Step 2: Update Dependencies +```bash +cargo update +``` + +## Step 3: Check for Deprecations & Warnings +```bash +cargo check +``` + +## Step 5: Run Quality Checks +```bash +cargo clippy +cargo fmt --check +``` +``` + +## Step 5: Confirm Completion + +Tell the user: +- ✅ `/update-app` created +- 🔄 Updates: [package manager commands] +- ⚠️ Zero-tolerance for deprecations/warnings +- 🛡️ Security audit included +- ✨ Clean install verification enabled diff --git a/plugin.lock.json b/plugin.lock.json new file mode 100644 index 0000000..dacccf7 --- /dev/null +++ b/plugin.lock.json @@ -0,0 +1,57 @@ +{ + "$schema": "internal://schemas/plugin.lock.v1.json", + "pluginId": "gh:KenKaiii/minimal-claude:", + "normalized": { + "repo": null, + "ref": "refs/tags/v20251128.0", + "commit": "bea12c9dbc0970dd6bbeae5169334a6ad659d20a", + "treeHash": "3e841a65e7cabb9ebd38283edca9cb9e734bb5aa171ad0006a78eb806508b98c", + "generatedAt": "2025-11-28T10:11:59.030761Z", + "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": "minimal-claude", + "description": "Auto-configure code quality tools and generate custom /fix command for parallel agent-based fixing", + "version": "1.4.0" + }, + "content": { + "files": [ + { + "path": "README.md", + "sha256": "f03a626234e3e3e5c9d98dd666796d53936e650c8f4a1f5009dd939f17f42940" + }, + { + "path": ".claude-plugin/plugin.json", + "sha256": "3b87d6b83448d835622e3b36a8b84dd53d3dfff0d8c8be2887ed3497038bde0f" + }, + { + "path": "commands/setup-updates.md", + "sha256": "24fe551d8eb3ae3e6b11a1746c714e627cb35276b8b2635a6dba7e20e906caf3" + }, + { + "path": "commands/setup-commits.md", + "sha256": "14ff63f41573afa994d3061b5a34526159fb429070b724125c7632180a2a6481" + }, + { + "path": "commands/setup-code-quality.md", + "sha256": "7e5d03a30e056b6160fce98437d1f2263a88a56424340b0406e98618cc9a0b93" + }, + { + "path": "commands/setup-claude-md.md", + "sha256": "ad749525961e4bfeb2762c49e4dd66d31ead7353314884bccc8f392edaba4564" + } + ], + "dirSha256": "3e841a65e7cabb9ebd38283edca9cb9e734bb5aa171ad0006a78eb806508b98c" + }, + "security": { + "scannedAt": null, + "scannerVersion": null, + "flags": [] + } +} \ No newline at end of file