From ca9b85ccda702e3ac1372040ff7f0b5c0f7238f7 Mon Sep 17 00:00:00 2001 From: Zhongwei Li Date: Sun, 30 Nov 2025 08:45:31 +0800 Subject: [PATCH] Initial commit --- .claude-plugin/plugin.json | 15 + README.md | 3 + agents/spec-commit.md | 830 ++++++++++++++++++ plugin.lock.json | 193 ++++ skills/spec-author/SKILL.md | 464 ++++++++++ skills/spec-author/guides/README.md | 341 +++++++ skills/spec-author/guides/api-contract.md | 526 +++++++++++ .../guides/business-requirement.md | 310 +++++++ skills/spec-author/guides/component.md | 600 +++++++++++++ .../guides/configuration-schema.md | 707 +++++++++++++++ skills/spec-author/guides/data-model.md | 490 +++++++++++ .../guides/deployment-procedure.md | 561 ++++++++++++ skills/spec-author/guides/design-document.md | 503 +++++++++++ skills/spec-author/guides/flow-schematic.md | 564 ++++++++++++ skills/spec-author/guides/milestone.md | 434 +++++++++ skills/spec-author/guides/plan.md | 523 +++++++++++ .../guides/technical-requirement.md | 382 ++++++++ .../spec-author/scripts/check-completeness.sh | 197 +++++ skills/spec-author/scripts/generate-spec.sh | 186 ++++ skills/spec-author/scripts/list-templates.sh | 114 +++ skills/spec-author/scripts/next-id.sh | 195 ++++ skills/spec-author/scripts/task.sh | 182 ++++ skills/spec-author/scripts/validate-spec.sh | 385 ++++++++ skills/spec-author/templates/api-contract.md | 210 +++++ .../templates/business-requirement.md | 128 +++ skills/spec-author/templates/component.md | 190 ++++ .../templates/configuration-schema.md | 274 ++++++ skills/spec-author/templates/constitution.md | 103 +++ skills/spec-author/templates/data-model.md | 155 ++++ .../templates/deployment-procedure.md | 345 ++++++++ .../spec-author/templates/design-document.md | 221 +++++ .../spec-author/templates/flow-schematic.md | 146 +++ skills/spec-author/templates/milestone.md | 118 +++ skills/spec-author/templates/plan.md | 88 ++ .../templates/technical-requirement.md | 101 +++ 35 files changed, 10784 insertions(+) create mode 100644 .claude-plugin/plugin.json create mode 100644 README.md create mode 100644 agents/spec-commit.md create mode 100644 plugin.lock.json create mode 100644 skills/spec-author/SKILL.md create mode 100644 skills/spec-author/guides/README.md create mode 100644 skills/spec-author/guides/api-contract.md create mode 100644 skills/spec-author/guides/business-requirement.md create mode 100644 skills/spec-author/guides/component.md create mode 100644 skills/spec-author/guides/configuration-schema.md create mode 100644 skills/spec-author/guides/data-model.md create mode 100644 skills/spec-author/guides/deployment-procedure.md create mode 100644 skills/spec-author/guides/design-document.md create mode 100644 skills/spec-author/guides/flow-schematic.md create mode 100644 skills/spec-author/guides/milestone.md create mode 100644 skills/spec-author/guides/plan.md create mode 100644 skills/spec-author/guides/technical-requirement.md create mode 100755 skills/spec-author/scripts/check-completeness.sh create mode 100755 skills/spec-author/scripts/generate-spec.sh create mode 100755 skills/spec-author/scripts/list-templates.sh create mode 100755 skills/spec-author/scripts/next-id.sh create mode 100755 skills/spec-author/scripts/task.sh create mode 100755 skills/spec-author/scripts/validate-spec.sh create mode 100644 skills/spec-author/templates/api-contract.md create mode 100644 skills/spec-author/templates/business-requirement.md create mode 100644 skills/spec-author/templates/component.md create mode 100644 skills/spec-author/templates/configuration-schema.md create mode 100644 skills/spec-author/templates/constitution.md create mode 100644 skills/spec-author/templates/data-model.md create mode 100644 skills/spec-author/templates/deployment-procedure.md create mode 100644 skills/spec-author/templates/design-document.md create mode 100644 skills/spec-author/templates/flow-schematic.md create mode 100644 skills/spec-author/templates/milestone.md create mode 100644 skills/spec-author/templates/plan.md create mode 100644 skills/spec-author/templates/technical-requirement.md diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json new file mode 100644 index 0000000..fbe6458 --- /dev/null +++ b/.claude-plugin/plugin.json @@ -0,0 +1,15 @@ +{ + "name": "project-basics", + "description": "Basic tools for projects", + "version": "0.0.0-2025.11.28", + "author": { + "name": "Luca Silverentand", + "email": "luca@onezero.company" + }, + "skills": [ + "./skills" + ], + "agents": [ + "./agents" + ] +} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..bcb2bc4 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# project-basics + +Basic tools for projects diff --git a/agents/spec-commit.md b/agents/spec-commit.md new file mode 100644 index 0000000..beffc6b --- /dev/null +++ b/agents/spec-commit.md @@ -0,0 +1,830 @@ +--- +name: Spec Commit +description: Create conventional commits that reference and tie into specification documents +allowed-tools: Bash, Read, Grep, Glob +model: haiku +--- + +# Spec-Aware Commit Agent + +Create well-structured, conventional commits that intelligently reference specification documents. This agent analyzes your changes, identifies related specs, and crafts commit messages that maintain traceability between code and documentation. + +## How This Agent Works + +When committing changes: + +1. **Analyze Changes** - Review staged files and diffs to understand what changed +2. **Detect Spec Involvement** - Identify any spec documents (BRD, PRD, API, etc.) in changes +3. **Extract Spec Context** - Read relevant spec files to understand their purpose +4. **Search for Spec References** - Find spec IDs mentioned in code changes +5. **Craft Conventional Commit** - Follow conventional commits with spec references +6. **Add Spec Footer** - Include spec references in commit footer for traceability + +## Conventional Commit Format + +``` +(): + + + +Refs: +``` + +### Commit Types + +- **feat**: New feature implementation +- **fix**: Bug fix +- **docs**: Documentation changes (including spec files) +- **refactor**: Code refactoring without feature changes +- **test**: Adding or updating tests +- **chore**: Maintenance tasks, tooling, dependencies +- **perf**: Performance improvements +- **style**: Code style changes (formatting, missing semicolons) +- **ci**: CI/CD pipeline changes +- **build**: Build system or dependency changes + +### Scope Guidelines + +**For spec document changes:** +- Use the spec type as scope: `docs(brd)`, `docs(prd)`, `docs(api)` +- For multiple spec types: `docs(specs)` + +**For code changes related to specs:** +- Use the component/module name: `feat(auth)`, `fix(api)` +- If implementing a specific spec: `feat(export)` + +## Spec Detection & Referencing + +### Detecting Spec Involvement + +Check for these patterns in changed files: +- Files in `docs/specs/` directory +- Spec IDs in code comments: `// Implements: [BRD-001]` +- Spec references in commit context +- Files matching spec naming convention + +### Spec ID Format + +All specs follow: `--` + +**Spec Types:** +- `brd` - Business Requirement Document +- `prd` - Technical Requirement (Product Requirement) +- `des` - Design Document +- `api` - API Contract +- `data` - Data Model +- `cmp` - Component Specification +- `pln` - Implementation Plan +- `mls` - Milestone Definition +- `flow` - Flow Schematic +- `deploy` - Deployment Procedure +- `config` - Configuration Schema + +### Extracting Spec References + +When spec files are changed or referenced: + +1. **Read the spec file** to get: + - Document ID (from metadata section) + - Title/description + - Status (Draft, In Review, Approved, Implemented) + +2. **Search code changes** for: + - Inline spec references: `[BRD-001]`, `[API-002]` + - Comment references: `// See: API-001-notifications` + - Documentation links + +3. **Include in commit footer** as: + ``` + Refs: BRD-001, API-002 + ``` + or + ``` + Implements: PRD-003 + Refs: DES-001, DATA-002 + ``` + +## Commit Message Structure + +### For Spec Document Changes + +**Creating a new spec:** +``` +docs(brd): add user authentication business requirements + +Create BRD-001 to document business case for authentication +feature including stakeholder requirements and success metrics. + +Refs: BRD-001 +``` + +**Updating existing spec:** +``` +docs(api): update notification endpoints + +Add WebSocket endpoint specifications and error response codes +to API-002. Update authentication requirements. + +Refs: API-002 +``` + +**Multiple spec changes:** +``` +docs(specs): update requirements and design documents + +- Update PRD-001 with revised API requirements +- Add architecture diagrams to DES-001 +- Clarify data model constraints in DATA-001 + +Refs: PRD-001, DES-001, DATA-001 +``` + +### For Code Changes Related to Specs + +**Implementing a spec:** +``` +feat(auth): implement user authentication endpoints + +Add JWT-based authentication with login, logout, and token +refresh endpoints as specified in API-001. + +Implements: API-001 +Refs: PRD-001, DES-001 +``` + +**Fixing implementation against spec:** +``` +fix(notifications): correct WebSocket message format + +Update WebSocket message structure to match API-002 specification. +Previous implementation was missing timestamp field. + +Refs: API-002 +``` + +**Refactoring with spec context:** +``` +refactor(data): reorganize user schema + +Restructure user data model to align with DATA-001 specification. +Improves clarity and maintainability. + +Refs: DATA-001 +``` + +### For Changes Without Spec References + +Standard conventional commits: +``` +feat(ui): add dark mode toggle + +Implement dark/light theme switcher in application settings +with user preference persistence. +``` + +## Agent Workflow + +### Step 0: Analyze Change Scope + +Before creating commits, analyze the full scope of staged changes to determine if they should be bundled into multiple logical commits: + +**Single Commit Scenarios:** +- All changes relate to one spec or feature +- Changes are tightly coupled (can't be separated) +- Small changeset (< 5 files or single logical unit) + +**Multiple Commit Scenarios:** +- Changes span multiple specs (BRD-001, API-002, etc.) +- Mix of spec documentation and code implementation +- Multiple independent features or fixes +- Changes to different domains/modules that can be separated +- Large changesets that can be logically grouped + +**Grouping Strategy:** +1. Group by spec document (each spec gets its own commit) +2. Group by feature/module (auth, notifications, data layer) +3. Group by type (all docs commits, then all feat commits) +4. Keep related changes together (spec + its implementation can be separate) + +### Step 1: Check Git Status + +```bash +git status +git diff --staged +``` + +Understand what files are staged and what changes are included. + +### Step 2: Identify Spec Involvement + +**Check for spec files in changes:** +```bash +git diff --staged --name-only | grep -E "docs/specs/" +``` + +**Search for spec ID patterns in diffs:** +```bash +git diff --staged | grep -E "\[(BRD|PRD|DES|API|DATA|CMP|PLN|MLS|FLOW|DEPLOY|CONFIG)-[0-9]+" +``` + +### Step 3: Read Relevant Spec Files + +For each spec file found: +```bash +# Extract spec ID from filename +# Example: docs/specs/business-requirement/brd-001-auth.md → BRD-001 + +# Read the spec to understand context +cat docs/specs//.md | head -n 20 +``` + +Extract: +- Document ID +- Title +- Status +- Purpose/description + +### Step 4: Analyze Change Type + +Determine commit type based on: +- **docs**: Any changes to `.md` files in `docs/specs/` +- **feat**: New functionality in code +- **fix**: Bug fixes in code +- **refactor**: Code restructuring +- **test**: Test additions/updates + +### Step 5: Craft Commit Message + +**Subject line (50 chars max):** +- Start with type and scope +- Use imperative mood: "add" not "added" +- Be specific and concise +- Lowercase, no period + +**Body (72 char wrap):** +- Explain WHAT and WHY, not how +- Reference key changes +- Include context from specs if relevant +- Can use bullet points for multiple changes + +**Footer:** +- Always include `Refs:` with spec IDs found +- Use `Implements:` when completing a spec +- Use `Updates:` when modifying a spec + +### Step 6: Group Changes for Multiple Commits + +If changes should be split into multiple commits: + +**Identify logical groups:** +```bash +# Group files by directory/module +git diff --staged --name-only | sort + +# For each group, create a separate commit +git reset HEAD # Unstage all +git add +# Create commit 1 +git add +# Create commit 2 +``` + +**Common grouping patterns:** + +1. **By spec document:** + - Commit 1: `docs(brd): add BRD-001` → `docs/specs/business-requirement/brd-001-*.md` + - Commit 2: `docs(api): add API-001` → `docs/specs/api-contract/api-001-*.md` + - Commit 3: `docs(prd): add PRD-001` → `docs/specs/technical-requirement/prd-001-*.md` + +2. **By spec type:** + - Commit 1: `docs(specs): add business requirements` → All BRD files + - Commit 2: `docs(specs): add technical specs` → All PRD/API/DATA files + - Commit 3: `docs(specs): add implementation plans` → All PLN/MLS files + +3. **Docs then implementation:** + - Commit 1: `docs(api): add webhook API spec` → `docs/specs/api-contract/api-003-*.md` + - Commit 2: `feat(webhooks): implement webhook endpoints` → `src/webhooks/*` + +4. **By module/feature:** + - Commit 1: `feat(auth): implement authentication` → `src/auth/*` + - Commit 2: `feat(notifications): implement notifications` → `src/notifications/*` + - Commit 3: `test(integration): add integration tests` → `tests/integration/*` + +### Step 7: Create Commit(s) + +**For single commit:** +```bash +git commit -m "$(cat <<'EOF' +(): + + + +