From 569a3de80bb869011adfe83ba96e895ad19216f6 Mon Sep 17 00:00:00 2001 From: phernandez Date: Tue, 3 Jun 2025 09:24:03 -0500 Subject: [PATCH] feat: add comprehensive custom Claude Code slash commands MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds custom slash commands for streamlined development workflow: Release Management (/project:release:*): - beta - Create beta releases with automated quality checks - release - Create stable releases with comprehensive validation - release-check - Pre-flight validation without making changes - changelog - Generate changelog entries from commits Development (/project:*): - test-coverage - Run tests with detailed coverage analysis - lint-fix - Comprehensive code quality fixes with auto-repair - check-health - Project health assessment and metrics Commands are organized in .claude/commands/ directory following Claude Code conventions and provide structured automation for common development tasks. ๐Ÿค– Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .claude/commands/check-health.md | 190 ++++++++++++++++++++++ .claude/commands/commands.md | 56 +++++++ .claude/commands/lint-fix.md | 145 +++++++++++++++++ .claude/commands/release/beta.md | 69 ++++++++ .claude/commands/release/changelog.md | 157 ++++++++++++++++++ .claude/commands/release/release-check.md | 131 +++++++++++++++ .claude/commands/release/release.md | 84 ++++++++++ .claude/commands/test-coverage.md | 131 +++++++++++++++ 8 files changed, 963 insertions(+) create mode 100644 .claude/commands/check-health.md create mode 100644 .claude/commands/commands.md create mode 100644 .claude/commands/lint-fix.md create mode 100644 .claude/commands/release/beta.md create mode 100644 .claude/commands/release/changelog.md create mode 100644 .claude/commands/release/release-check.md create mode 100644 .claude/commands/release/release.md create mode 100644 .claude/commands/test-coverage.md diff --git a/.claude/commands/check-health.md b/.claude/commands/check-health.md new file mode 100644 index 00000000..7a14c2ce --- /dev/null +++ b/.claude/commands/check-health.md @@ -0,0 +1,190 @@ +# /project:check-health - Project Health Assessment + +Comprehensive health check of the Basic Memory project including code quality, test coverage, dependencies, and documentation. + +## Usage +``` +/project:check-health +``` + +## Implementation + +You are an expert DevOps engineer for the Basic Memory project. When the user runs `/project:check-health`, execute the following comprehensive assessment: + +### Step 1: Git Repository Health +1. **Repository Status** + ```bash + git status + git log --oneline -5 + git branch -vv + ``` + - Check working directory status + - Verify branch alignment with remote + - Check recent commit activity + +2. **Branch Analysis** + - Verify on main branch + - Check if ahead/behind remote + - Identify any untracked files + +### Step 2: Code Quality Assessment +1. **Linting and Formatting** + ```bash + uv run ruff check . + uv run pyright + ``` + - Count linting issues by severity + - Check type annotation coverage + - Verify code formatting compliance + +2. **Test Suite Health** + ```bash + uv run pytest --collect-only -q + uv run pytest --co -q | wc -l + ``` + - Count total tests + - Check for test discovery issues + - Verify test structure integrity + +### Step 3: Dependency Analysis +1. **Dependency Health** + ```bash + uv tree + uv lock --dry-run + ``` + - Check for dependency conflicts + - Identify outdated dependencies + - Verify lock file consistency + +2. **Security Scan** + ```bash + uv run pip-audit --desc + ``` + - Scan for known vulnerabilities + - Check dependency licenses + - Identify security advisories + +### Step 4: Performance Metrics +1. **Test Performance** + ```bash + uv run pytest --durations=10 + ``` + - Identify slowest tests + - Check overall test execution time + - Monitor test suite growth + +2. **Build Performance** + ```bash + time uv run python -c "import basic_memory" + ``` + - Check import time + - Validate package installation + - Monitor startup performance + +### Step 5: Documentation Health +1. **Documentation Coverage** + - Check README.md currency + - Verify CLI documentation + - Validate MCP tool documentation + - Check changelog completeness + +2. **API Documentation** + - Verify docstring coverage + - Check type annotation completeness + - Validate example code + +### Step 6: Project Metrics +1. **Code Statistics** + ```bash + find src -name "*.py" | xargs wc -l + find tests -name "*.py" | xargs wc -l + ``` + - Lines of code trends + - Test-to-code ratio + - File organization metrics + +## Health Report Format + +Generate comprehensive health dashboard: + +``` +๐Ÿฅ Basic Memory Project Health Report + +๐Ÿ“Š OVERALL HEALTH: ๐ŸŸข EXCELLENT (92/100) + +๐Ÿ—‚๏ธ GIT REPOSITORY +โœ… Clean working directory +โœ… Up to date with origin/main +โœ… Recent commit activity (5 commits this week) + +๐Ÿ” CODE QUALITY +โœ… Linting: 0 errors, 2 warnings +โœ… Type checking: 100% coverage +โœ… Formatting: Compliant +โš ๏ธ Complex functions: 3 need refactoring + +๐Ÿงช TEST SUITE +โœ… Total tests: 744 +โœ… Test discovery: All tests found +โœ… Coverage: 98.2% +โšก Performance: 45.2s (good) + +๐Ÿ“ฆ DEPENDENCIES +โœ… Dependencies: Up to date +โœ… Security: No vulnerabilities +โœ… Conflicts: None detected +โš ๏ธ Outdated: 2 minor updates available + +๐Ÿ“– DOCUMENTATION +โœ… README: Current +โœ… API docs: 95% coverage +โš ๏ธ CLI reference: Needs update +โœ… Changelog: Complete + +๐Ÿ“ˆ METRICS +โ”œโ”€โ”€ Source code: 15,432 lines +โ”œโ”€โ”€ Test code: 8,967 lines +โ”œโ”€โ”€ Test ratio: 58% (excellent) +โ””โ”€โ”€ Complexity: Low (maintainable) + +๐ŸŽฏ RECOMMENDATIONS: +1. Update CLI documentation +2. Refactor 3 complex functions +3. Update minor dependencies +4. Consider splitting large test files + +๐Ÿ† PROJECT STATUS: Ready for v0.13.0 release! +``` + +## Health Scoring + +### Excellent (90-100) +- All quality gates pass +- High test coverage (>95%) +- No security issues +- Documentation current + +### Good (75-89) +- Minor issues present +- Good test coverage (>90%) +- No critical security issues +- Most documentation current + +### Needs Attention (60-74) +- Several quality issues +- Adequate test coverage (>80%) +- Minor security concerns +- Documentation gaps + +### Critical (<60) +- Major quality problems +- Low test coverage (<80%) +- Security vulnerabilities +- Significant documentation issues + +## Context +- Provides comprehensive project overview +- Identifies potential issues before they become problems +- Tracks project health trends over time +- Helps prioritize maintenance tasks +- Supports release readiness decisions \ No newline at end of file diff --git a/.claude/commands/commands.md b/.claude/commands/commands.md new file mode 100644 index 00000000..cd818c26 --- /dev/null +++ b/.claude/commands/commands.md @@ -0,0 +1,56 @@ +# Basic Memory Custom Commands + +This directory contains custom Claude Code slash commands for the Basic Memory project. + +## Available Commands + +### Release Management (`/project:release:*`) +- `/project:release:beta` - Create beta releases with automated quality checks +- `/project:release:release` - Create stable releases with comprehensive validation +- `/project:release:release-check` - Pre-flight validation without making changes +- `/project:release:changelog` - Generate changelog entries from commits + +### Development (`/project:*`) +- `/project:test-coverage` - Run tests with detailed coverage analysis +- `/project:fix-imports` - Clean up and organize imports +- `/project:lint-fix` - Run comprehensive linting with auto-fix + +## Command Structure + +Commands are organized by functionality: +``` +.claude/commands/ +โ”œโ”€โ”€ release/ # Release management commands +โ”‚ โ”œโ”€โ”€ beta.md # /project:release:beta +โ”‚ โ”œโ”€โ”€ release.md # /project:release:release +โ”‚ โ”œโ”€โ”€ release-check.md # /project:release:release-check +โ”‚ โ””โ”€โ”€ changelog.md # /project:release:changelog +โ”œโ”€โ”€ test-coverage.md # /project:test-coverage +โ””โ”€โ”€ commands.md # This overview file +``` + +## Usage + +Commands are invoked using the `/project:` prefix: +- `/project:release:beta v0.13.0b4` +- `/project:test-coverage mcp` +- `/project:release:release-check` + +## Implementation + +Each command is implemented as a Markdown file containing structured prompts that: +1. Validate preconditions +2. Execute steps in the correct order +3. Handle errors gracefully +4. Provide clear status updates +5. Return actionable results + +## Tooling Integration + +Commands leverage existing project tooling: +- `make check` - Quality checks +- `make test` - Test suite +- `make update-deps` - Dependency updates +- `uv` - Package management +- `git` - Version control +- GitHub Actions - CI/CD pipeline \ No newline at end of file diff --git a/.claude/commands/lint-fix.md b/.claude/commands/lint-fix.md new file mode 100644 index 00000000..459c15a0 --- /dev/null +++ b/.claude/commands/lint-fix.md @@ -0,0 +1,145 @@ +# /project:lint-fix - Comprehensive Code Quality Fix + +Run comprehensive linting and auto-fix code quality issues across the codebase. + +## Usage +``` +/project:lint-fix +``` + +## Implementation + +You are an expert code quality engineer for the Basic Memory project. When the user runs `/project:lint-fix`, execute the following steps: + +### Step 1: Pre-flight Check +1. **Verify Clean Working Directory** + ```bash + git status --porcelain + ``` + - Check for uncommitted changes + - Warn if working directory is not clean + - Suggest stashing changes if needed + +### Step 2: Import Organization +1. **Fix Import Order and Cleanup** + ```bash + uv run ruff check --select I --fix . + ``` + - Sort imports by category (standard, third-party, local) + - Remove unused imports + - Fix import spacing and organization + +### Step 3: Code Formatting +1. **Apply Consistent Formatting** + ```bash + uv run ruff format . + ``` + - Format code according to project style + - Fix line length issues (100 chars max) + - Standardize quotes and spacing + +### Step 4: Linting with Auto-fix +1. **Fix Linting Issues** + ```bash + uv run ruff check --fix . + ``` + - Auto-fix safe linting issues + - Report any remaining manual fixes needed + - Focus on code quality and best practices + +### Step 5: Type Checking +1. **Validate Type Annotations** + ```bash + uv run pyright + ``` + - Check for type errors + - Report any missing type annotations + - Validate type compatibility + +### Step 6: Report Generation +Generate comprehensive quality report: + +``` +๐Ÿ”ง Code Quality Fix Report + +โœ… FIXES APPLIED: +โ”œโ”€โ”€ Import organization: 12 files updated +โ”œโ”€โ”€ Code formatting: 8 files reformatted +โ”œโ”€โ”€ Auto-fixable lint issues: 23 issues resolved +โ””โ”€โ”€ Total files processed: 156 + +โš ๏ธ MANUAL ATTENTION NEEDED: +โ”œโ”€โ”€ Type annotations missing in entity_service.py:45 +โ”œโ”€โ”€ Complex function needs refactoring in sync_service.py:123 +โ””โ”€โ”€ Unused variable in test_utils.py:67 + +๐ŸŽฏ QUALITY SCORE: 96.2% (excellent) + +๐Ÿ“ Run `git diff` to review all changes +``` + +## Error Handling + +### Common Issues +- **Merge Conflicts**: Provide resolution guidance +- **Syntax Errors**: Point to specific files and lines +- **Type Errors**: Suggest specific fixes +- **Import Errors**: Check for missing dependencies + +### Recovery Steps +- If auto-fixes introduce issues, provide rollback instructions +- If type checking fails, suggest incremental fixes +- If tests break, provide debugging guidance + +## Quality Gates + +### Must Pass +- [ ] All auto-fixable lint issues resolved +- [ ] Code formatting consistent +- [ ] No syntax errors +- [ ] Import organization clean + +### Should Pass (Warnings) +- [ ] No type checking errors +- [ ] No complex function warnings +- [ ] No unused variables/imports +- [ ] Consistent naming conventions + +## Output Examples + +### Successful Fix +``` +๐ŸŽ‰ CODE QUALITY IMPROVED! + +โœ… All auto-fixes applied successfully +๐Ÿ“ Code formatting: 100% compliant +๐Ÿ” Linting: No issues found +๐Ÿท๏ธ Type checking: All passed + +Ready for commit! Use: +git add -A && git commit -m "style: fix code quality issues" +``` + +### Issues Requiring Attention +``` +โš ๏ธ PARTIAL SUCCESS - MANUAL FIXES NEEDED + +โœ… Auto-fixes applied: 45 issues +โŒ Manual fixes needed: 3 issues + +Priority fixes: +1. Fix type annotation in services/entity_service.py:142 +2. Simplify complex function in sync/sync_service.py:67 +3. Remove unused import in tests/conftest.py:12 + +Run these commands: +# Fix specific file +uv run pyright src/basic_memory/services/entity_service.py +``` + +## Context +- Uses ruff for fast Python linting and formatting +- Uses pyright for type checking +- Follows project code style guidelines (100 char line length) +- Maintains backward compatibility +- Integrates with existing pre-commit hooks \ No newline at end of file diff --git a/.claude/commands/release/beta.md b/.claude/commands/release/beta.md new file mode 100644 index 00000000..496cb813 --- /dev/null +++ b/.claude/commands/release/beta.md @@ -0,0 +1,69 @@ +# /beta - Create Beta Release + +Create a new beta release for the current version with automated quality checks and tagging. + +## Usage +``` +/beta [version] +``` + +**Parameters:** +- `version` (optional): Beta version like `v0.13.0b4`. If not provided, auto-increments from latest beta tag. + +## Implementation + +You are an expert release manager for the Basic Memory project. When the user runs `/beta`, execute the following steps: + +### Step 1: Pre-flight Checks +1. Check current git status for uncommitted changes +2. Verify we're on the `main` branch +3. Get the latest beta tag to determine next version if not provided + +### Step 2: Quality Assurance +1. Run `make check` to ensure code quality +2. If any checks fail, report issues and stop +3. Run `make update-deps` to ensure latest dependencies +4. Commit any dependency updates with proper message + +### Step 3: Version Determination +If version not provided: +1. Get latest git tags with `git tag -l "v*b*" --sort=-version:refname | head -1` +2. Auto-increment beta number (e.g., `v0.13.0b2` โ†’ `v0.13.0b3`) +3. Confirm version with user before proceeding + +### Step 4: Release Creation +1. Commit any remaining changes +2. Push to main: `git push origin main` +3. Create tag: `git tag {version}` +4. Push tag: `git push origin {version}` + +### Step 5: Monitor Release +1. Check GitHub Actions workflow starts successfully +2. Provide installation instructions for beta +3. Report status and next steps + +## Error Handling +- If quality checks fail, provide specific fix instructions +- If git operations fail, provide manual recovery steps +- If GitHub Actions fail, provide debugging guidance + +## Success Output +``` +โœ… Beta Release v0.13.0b4 Created Successfully! + +๐Ÿท๏ธ Tag: v0.13.0b4 +๐Ÿš€ GitHub Actions: Running +๐Ÿ“ฆ PyPI: Will be available in ~5 minutes + +Install with: +uv tool upgrade basic-memory --prerelease=allow + +Monitor release: https://github.com/basicmachines-co/basic-memory/actions +``` + +## Context +- Use the existing Makefile targets (`make check`, `make update-deps`) +- Follow semantic versioning for beta releases +- Maintain release notes in CHANGELOG.md +- Use conventional commit messages +- Leverage uv-dynamic-versioning for version management \ No newline at end of file diff --git a/.claude/commands/release/changelog.md b/.claude/commands/release/changelog.md new file mode 100644 index 00000000..d0a5d4cb --- /dev/null +++ b/.claude/commands/release/changelog.md @@ -0,0 +1,157 @@ +# /changelog - Generate or Update Changelog Entry + +Analyze commits and generate formatted changelog entry for a version. + +## Usage +``` +/changelog [type] +``` + +**Parameters:** +- `version` (required): Version like `v0.13.0` or `v0.13.0b4` +- `type` (optional): `beta`, `rc`, or `stable` (default: `stable`) + +## Implementation + +You are an expert technical writer for the Basic Memory project. When the user runs `/changelog`, execute the following steps: + +### Step 1: Version Analysis +1. **Determine Commit Range** + ```bash + # Find last release tag + git tag -l "v*" --sort=-version:refname | grep -v "b\|rc" | head -1 + + # Get commits since last release + git log --oneline ${last_tag}..HEAD + ``` + +2. **Parse Conventional Commits** + - Extract feat: (features) + - Extract fix: (bug fixes) + - Extract BREAKING CHANGE: (breaking changes) + - Extract chore:, docs:, test: (other improvements) + +### Step 2: Categorize Changes +1. **Features (feat:)** + - New MCP tools + - New CLI commands + - New API endpoints + - Major functionality additions + +2. **Bug Fixes (fix:)** + - User-facing bug fixes + - Critical issues resolved + - Performance improvements + - Security fixes + +3. **Technical Improvements** + - Test coverage improvements + - Code quality enhancements + - Dependency updates + - Documentation updates + +4. **Breaking Changes** + - API changes + - Configuration changes + - Behavior changes + - Migration requirements + +### Step 3: Generate Changelog Entry +Create formatted entry following existing CHANGELOG.md style: + +```markdown +## v0.13.0 (2025-06-03) + +### Features + +- **Multi-Project Management System** - Switch between projects instantly during conversations + ([`993e88a`](https://github.com/basicmachines-co/basic-memory/commit/993e88a)) + - Instant project switching with session context + - Project-specific operations and isolation + - Project discovery and management tools + +- **Advanced Note Editing** - Incremental editing with append, prepend, find/replace, and section operations + ([`6fc3904`](https://github.com/basicmachines-co/basic-memory/commit/6fc3904)) + - `edit_note` tool with multiple operation types + - Smart frontmatter-aware editing + - Validation and error handling + +### Bug Fixes + +- **#118**: Fix YAML tag formatting to follow standard specification + ([`2dc7e27`](https://github.com/basicmachines-co/basic-memory/commit/2dc7e27)) + +- **#110**: Make --project flag work consistently across CLI commands + ([`02dd91a`](https://github.com/basicmachines-co/basic-memory/commit/02dd91a)) + +### Technical Improvements + +- **Comprehensive Testing** - 100% test coverage with integration testing + ([`468a22f`](https://github.com/basicmachines-co/basic-memory/commit/468a22f)) + - MCP integration test suite + - End-to-end testing framework + - Performance and edge case validation + +### Breaking Changes + +- **Database Migration**: Automatic migration from per-project to unified database. + Data will be re-index from the filesystem, resulting in no data loss. +- **Configuration Changes**: Projects now synced between config.json and database +- **Full Backward Compatibility**: All existing setups continue to work seamlessly +``` + +### Step 4: Integration +1. **Update CHANGELOG.md** + - Insert new entry at top + - Maintain consistent formatting + - Include commit links and issue references + +2. **Validation** + - Check all major changes are captured + - Verify commit links work + - Ensure issue numbers are correct + +## Smart Analysis Features + +### Automatic Classification +- Detect feature additions from file changes +- Identify bug fixes from commit messages +- Find breaking changes from code analysis +- Extract issue numbers from commit messages + +### Content Enhancement +- Add context for technical changes +- Include migration guidance for breaking changes +- Suggest installation/upgrade instructions +- Link to relevant documentation + +## Output Format + +### For Beta Releases +```markdown +## v0.13.0b4 (2025-06-03) + +### Beta Changes Since v0.13.0b3 + +- Fix FastMCP API compatibility issues +- Update dependencies to latest versions +- Resolve setuptools import error + +### Installation +```bash +uv tool install basic-memory --prerelease=allow +``` + +### Known Issues +- [List any known issues for beta testing] +``` + +### For Stable Releases +Full changelog with complete feature list, organized by impact and category. + +## Context +- Follows existing CHANGELOG.md format and style +- Uses conventional commit standards +- Includes GitHub commit links for traceability +- Focuses on user-facing changes and value +- Maintains consistency with previous entries \ No newline at end of file diff --git a/.claude/commands/release/release-check.md b/.claude/commands/release/release-check.md new file mode 100644 index 00000000..36ef3c6a --- /dev/null +++ b/.claude/commands/release/release-check.md @@ -0,0 +1,131 @@ +# /release-check - Pre-flight Release Validation + +Comprehensive pre-flight check for release readiness without making any changes. + +## Usage +``` +/release-check [version] +``` + +**Parameters:** +- `version` (optional): Version to validate like `v0.13.0`. If not provided, determines from context. + +## Implementation + +You are an expert QA engineer for the Basic Memory project. When the user runs `/release-check`, execute the following validation steps: + +### Step 1: Environment Validation +1. **Git Status Check** + - Verify working directory is clean + - Confirm on `main` branch + - Check if ahead/behind origin + +2. **Version Validation** + - Validate version format if provided + - Check for existing tags with same version + - Verify version increments properly from last release + +### Step 2: Code Quality Gates +1. **Test Suite Validation** + ```bash + make test + ``` + - All tests must pass + - Check test coverage (target: 95%+) + - Validate no skipped critical tests + +2. **Code Quality Checks** + ```bash + make lint + make type-check + ``` + - No linting errors + - No type checking errors + - Code formatting is consistent + +### Step 3: Documentation Validation +1. **Changelog Check** + - CHANGELOG.md contains entry for target version + - Entry includes all major features and fixes + - Breaking changes are documented + +2. **Documentation Currency** + - README.md reflects current functionality + - CLI reference is up to date + - MCP tools are documented + +### Step 4: Dependency Validation +1. **Security Scan** + - No known vulnerabilities in dependencies + - All dependencies are at appropriate versions + - No conflicting dependency versions + +2. **Build Validation** + - Package builds successfully + - All required files are included + - No missing dependencies + +### Step 5: Issue Tracking Validation +1. **GitHub Issues Check** + - No critical open issues blocking release + - All milestone issues are resolved + - High-priority bugs are fixed + +2. **Testing Coverage** + - Integration tests pass + - MCP tool tests pass + - Cross-platform compatibility verified + +## Report Format + +Generate a comprehensive report: + +``` +๐Ÿ” Release Readiness Check for v0.13.0 + +โœ… PASSED CHECKS: +โ”œโ”€โ”€ Git status clean +โ”œโ”€โ”€ On main branch +โ”œโ”€โ”€ All tests passing (744/744) +โ”œโ”€โ”€ Test coverage: 98.2% +โ”œโ”€โ”€ Type checking passed +โ”œโ”€โ”€ Linting passed +โ”œโ”€โ”€ CHANGELOG.md updated +โ””โ”€โ”€ No critical issues open + +โš ๏ธ WARNINGS: +โ”œโ”€โ”€ 2 medium-priority issues still open +โ””โ”€โ”€ Documentation could be updated + +โŒ BLOCKING ISSUES: +โ””โ”€โ”€ None found + +๐ŸŽฏ RELEASE READINESS: โœ… READY + +Recommended next steps: +1. Address warnings if desired +2. Run `/release v0.13.0` when ready +``` + +## Validation Criteria + +### Must Pass (Blocking) +- [ ] All tests pass +- [ ] No type errors +- [ ] No linting errors +- [ ] Working directory clean +- [ ] On main branch +- [ ] CHANGELOG.md has version entry +- [ ] No critical open issues + +### Should Pass (Warnings) +- [ ] Test coverage >95% +- [ ] No medium-priority open issues +- [ ] Documentation up to date +- [ ] No dependency vulnerabilities + +## Context +- This is a read-only validation - makes no changes +- Provides confidence before running actual release +- Helps identify issues early in release process +- Can be run multiple times safely \ No newline at end of file diff --git a/.claude/commands/release/release.md b/.claude/commands/release/release.md new file mode 100644 index 00000000..47f432c7 --- /dev/null +++ b/.claude/commands/release/release.md @@ -0,0 +1,84 @@ +# /release - Create Stable Release + +Create a stable release from the current main branch with comprehensive validation. + +## Usage +``` +/release +``` + +**Parameters:** +- `version` (required): Release version like `v0.13.0` + +## Implementation + +You are an expert release manager for the Basic Memory project. When the user runs `/release`, execute the following steps: + +### Step 1: Pre-flight Validation +1. Verify version format matches `v\d+\.\d+\.\d+` pattern +2. Check current git status for uncommitted changes +3. Verify we're on the `main` branch +4. Confirm no existing tag with this version + +### Step 2: Comprehensive Quality Checks +1. Run `make check` (lint, format, type-check, full test suite) +2. Verify test coverage meets minimum requirements (95%+) +3. Check that CHANGELOG.md contains entry for this version +4. Validate all high-priority issues are closed + +### Step 3: Release Preparation +1. Update any version references if needed +2. Commit any final changes with message: `chore: prepare for ${version} release` +3. Push to main: `git push origin main` + +### Step 4: Release Creation +1. Create annotated tag: `git tag -a ${version} -m "Release ${version}"` +2. Push tag: `git push origin ${version}` +3. Monitor GitHub Actions for release automation + +### Step 5: Post-Release Validation +1. Verify GitHub release is created automatically +2. Check PyPI publication +3. Validate release assets +4. Test installation: `uv tool install basic-memory` + +### Step 6: Documentation Update +1. Update any post-release documentation +2. Create follow-up tasks if needed + +## Pre-conditions Check +Before starting, verify: +- [ ] All beta testing is complete +- [ ] Critical bugs are fixed +- [ ] Breaking changes are documented +- [ ] CHANGELOG.md is updated +- [ ] Version number follows semantic versioning + +## Error Handling +- If any quality check fails, stop and provide fix instructions +- If changelog entry missing, prompt to create one +- If tests fail, provide debugging guidance +- If GitHub Actions fail, provide manual release steps + +## Success Output +``` +๐ŸŽ‰ Stable Release v0.13.0 Created Successfully! + +๐Ÿท๏ธ Tag: v0.13.0 +๐Ÿ“‹ GitHub Release: https://github.com/basicmachines-co/basic-memory/releases/tag/v0.13.0 +๐Ÿ“ฆ PyPI: https://pypi.org/project/basic-memory/0.13.0/ +๐Ÿš€ GitHub Actions: Completed + +Install with: +uv tool install basic-memory + +Users can now upgrade: +uv tool upgrade basic-memory +``` + +## Context +- This creates production releases used by end users +- Must pass all quality gates before proceeding +- Follows the release workflow documented in CLAUDE.md +- Uses uv-dynamic-versioning for automatic version management +- Triggers automated GitHub release with changelog \ No newline at end of file diff --git a/.claude/commands/test-coverage.md b/.claude/commands/test-coverage.md new file mode 100644 index 00000000..4d078221 --- /dev/null +++ b/.claude/commands/test-coverage.md @@ -0,0 +1,131 @@ +# /test-coverage - Run Tests with Coverage Analysis + +Execute test suite with comprehensive coverage reporting and analysis. + +## Usage +``` +/test-coverage [pattern] +``` + +**Parameters:** +- `pattern` (optional): Test pattern to run specific tests (e.g., `test_mcp`, `*integration*`) + +## Implementation + +You are an expert QA engineer for the Basic Memory project. When the user runs `/test-coverage`, execute the following steps: + +### Step 1: Test Execution +1. **Run Tests with Coverage** + ```bash + # Full test suite + uv run pytest --cov=basic_memory --cov-report=html --cov-report=term -v + + # Or with pattern if provided + uv run pytest tests/*{pattern}* --cov=basic_memory --cov-report=html --cov-report=term -v + ``` + +2. **Generate Coverage Reports** + - Terminal summary with percentages + - HTML report for detailed analysis + - Identify files below coverage threshold + +### Step 2: Coverage Analysis +1. **Summary Statistics** + - Overall coverage percentage + - Number of files with 100% coverage + - Files below 95% threshold + - Total lines covered/missed + +2. **Detailed Breakdown** + - Coverage by module/package + - Identify untested code paths + - Find missing edge case tests + +### Step 3: Report Generation +Generate comprehensive coverage report: + +``` +๐Ÿงช Test Coverage Report + +๐Ÿ“Š OVERALL COVERAGE: 98.2% (target: 95%+) + +โœ… EXCELLENT COVERAGE (>95%): +โ”œโ”€โ”€ basic_memory/mcp/: 99.1% +โ”œโ”€โ”€ basic_memory/services/: 98.8% +โ”œโ”€โ”€ basic_memory/repository/: 97.9% +โ””โ”€โ”€ basic_memory/api/: 96.2% + +โš ๏ธ NEEDS ATTENTION (<95%): +โ”œโ”€โ”€ basic_memory/sync/: 94.1% (missing 12 lines) +โ””โ”€โ”€ basic_memory/importers/: 91.8% (missing 23 lines) + +๐ŸŽฏ SPECIFIC GAPS: +โ”œโ”€โ”€ sync_service.py:142-145 (error handling) +โ”œโ”€โ”€ importer_base.py:67-70 (edge case) +โ””โ”€โ”€ file_utils.py:89 (exception path) + +๐Ÿ“ HTML Report: htmlcov/index.html +๐Ÿš€ Run `open htmlcov/index.html` to view detailed report +``` + +### Step 4: Actionable Recommendations +1. **Coverage Improvements** + - Suggest specific tests to add + - Identify edge cases to cover + - Recommend integration tests + +2. **Quality Insights** + - Highlight well-tested modules + - Point out testing patterns to follow + - Suggest refactoring for testability + +## Advanced Analysis + +### Performance Metrics +- Test execution time by module +- Slowest tests identification +- Coverage collection overhead + +### Integration Coverage +- MCP tool integration tests +- API endpoint coverage +- Database operation coverage +- File system operation coverage + +## Output Examples + +### Full Coverage Success +``` +๐ŸŽ‰ EXCELLENT COVERAGE! + +๐Ÿ“Š Coverage: 98.7% (744 tests passed) +โœ… All modules above 95% threshold +๐Ÿ† 23 files with 100% coverage +โšก Tests completed in 45.2s + +Ready for release! ๐Ÿš€ +``` + +### Coverage Issues Found +``` +โš ๏ธ COVERAGE GAPS DETECTED + +๐Ÿ“Š Coverage: 92.1% (below 95% target) +โŒ 3 modules need attention +๐Ÿ” 43 uncovered lines found + +Priority fixes: +1. Add tests for error handling in sync_service.py +2. Cover edge cases in importer_base.py +3. Test exception paths in file_utils.py + +Run specific tests: +uv run pytest tests/sync/ -v +``` + +## Context +- Uses pytest with coverage plugin +- Generates both terminal and HTML reports +- Focuses on actionable improvement suggestions +- Integrates with existing test infrastructure +- Helps maintain high code quality standards \ No newline at end of file