-
Notifications
You must be signed in to change notification settings - Fork 37
feat: implement memory system for better Claude Code context #359
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: implement memory system for better Claude Code context #359
Conversation
Adds a structured memory system to provide targeted, loadable context:
**Components implemented:**
1. Context Files (.claude/context/)
- backend-development.md - Go backend, K8s integration patterns
- frontend-development.md - NextJS, Shadcn UI, React Query patterns
- security-standards.md - Auth, RBAC, token handling
2. ADR Infrastructure (docs/adr/)
- Template and README for creating ADRs
- 5 critical ADRs documenting architectural decisions:
* 0001-kubernetes-native-architecture.md
* 0002-user-token-authentication.md
* 0003-multi-repo-support.md
* 0004-go-backend-python-runner.md
* 0005-nextjs-shadcn-react-query.md
3. Repomix Usage Guide (.claude/repomix-guide.md)
- When to use each of the 7 existing repomix views
- Example prompts for different scenarios
4. Decision Log (docs/decisions.md)
- Chronological record of major decisions
- Links to ADRs, code, and context files
5. Pattern Catalog (.claude/patterns/)
- error-handling.md - Consistent error patterns
- k8s-client-usage.md - User token vs service account
- react-query-usage.md - Data fetching patterns
**CLAUDE.md updated** with Memory System section providing quick
reference to all memory files and example usage prompts.
**Value:** Enables targeted context loading instead of relying solely
on comprehensive CLAUDE.md, improving response accuracy for specialized
tasks while keeping main docs focused on universal rules.
Resolves ambient-code#357
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Claude Code ReviewSummaryThis PR implements a well-structured memory system for Claude Code, providing targeted, loadable context through organized documentation files. The implementation is comprehensive, well-organized, and adds significant value to the developer experience. The documentation is clear, consistent, and follows established patterns. Overall Assessment: ✅ APPROVED - High-quality documentation work with minor suggestions for improvement. Issues by Severity🟡 Major Issues1. Line Number References May Become Stale
2. Missing Validation in Repomix Guide
🔵 Minor Issues3. Date Inconsistencies in Context Files
4. ADR Dates Don't Match Git History
5. Template Formatting in decisions.md
6. Missing Cross-References
Positive HighlightsExcellent Architecture:
Comprehensive Coverage:
High Documentation Quality:
Practical Value:
Excellent Integration:
RecommendationsPriority 1 (Address before merge):
Priority 2 (Nice to have):
Future Enhancements:
Maintenance Plan:
Testing Validation✅ All 16 files created successfully ConclusionThis is excellent documentation work that significantly improves the developer experience. The memory system is well-designed, comprehensive, and practical. The only significant issue is the use of specific line numbers that will become stale - recommend replacing with function-level references before merge. Recommendation: APPROVE with minor changes requested (line number references). Review completed by Claude Code on 2024-11-22 |
…-code#359) ## Summary Implements a structured memory system to provide targeted, loadable context instead of relying solely on the comprehensive CLAUDE.md file. ## Components Implemented ### 1. Context Files (`.claude/context/`) - `backend-development.md` - Go backend, K8s integration patterns - `frontend-development.md` - NextJS, Shadcn UI, React Query patterns - `security-standards.md` - Auth, RBAC, token handling ### 2. ADR Infrastructure (`docs/adr/`) - Template and README for creating ADRs - 5 critical ADRs documenting architectural decisions: * `0001-kubernetes-native-architecture.md` * `0002-user-token-authentication.md` * `0003-multi-repo-support.md` * `0004-go-backend-python-runner.md` * `0005-nextjs-shadcn-react-query.md` ### 3. Repomix Usage Guide (`.claude/repomix-guide.md`) - When to use each of the 7 existing repomix views - Example prompts for different scenarios - Best practices for combining views with context files ### 4. Decision Log (`docs/decisions.md`) - Chronological record of major decisions - Links to ADRs, code, and context files - Template for future entries ### 5. Pattern Catalog (`.claude/patterns/`) - `error-handling.md` - Consistent error patterns (backend, operator, runner) - `k8s-client-usage.md` - User token vs service account patterns - `react-query-usage.md` - Data fetching patterns (queries, mutations, caching) ### 6. CLAUDE.md Updated - Added Memory System section with quick reference table - Example usage prompts for loading context ## Value Proposition - **Targeted context loading**: Load only relevant context for specific tasks - **Reduced context bloat**: Keep main CLAUDE.md focused on universal rules - **Better decision traceability**: Document WHY decisions were made, not just WHAT - **Faster onboarding**: New Claude sessions understand context quickly - **Pattern reuse**: Codified best practices reduce reinventing the wheel ## Example Usage ``` "Claude, load the backend-development context file and the backend-focused repomix view (04), then help me add a new endpoint for listing RFE workflows in a project." ``` ``` "Claude, reference the security-standards context file and review this PR for token handling issues." ``` ``` "Claude, check ADR-0002 (User Token Authentication) and explain why we use user tokens instead of service accounts for API operations." ``` ## Testing - [x] All 16 files created successfully - [x] CLAUDE.md updated with Memory System section - [x] Markdownlint run on all new files (auto-fixed formatting) - [x] Git hooks validated (branch protection working correctly) ## Acceptance Criteria (from issue ambient-code#357) - [x] All files created per implementation plan - [x] CLAUDE.md updated with memory system section - [x] Claude can successfully reference memory files in new session - [x] Example prompts tested and verified working Closes ambient-code#357 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <noreply@anthropic.com>
## Summary This PR introduces a **simplified memory system** with a single, high-quality repomix architecture view for Claude Code context loading. ### Executive Decision: Single View Approach After comprehensive analysis of 7 different repomix configurations (see `repomix-analysis/repomix-analysis-report.md`), we adopted a **single-view approach** using only `03-architecture-only.xml`. **Why one view?** - **Grade 8.8/10** - Highest quality score of all tested configurations - **187K tokens** - Optimal for context windows, leaves room for conversation - **Comprehensive coverage** - 132 critical files across all 7 components - **Simpler mental model** - No decision fatigue about which view to use - **Smaller repo** - 1M vs 19M (94% reduction) See the [analysis heatmap](repomix-analysis/repomix-heatmap.png) for visual comparison. ### What's Included **Memory System Files:** - `.repomixignore` - Configuration for repomix generation - `docs/implementation-plans/` - Design documentation (2 files) - `repomix-analysis/03-architecture-only.xml` - The single reference view - `repomix-analysis/repomix-analysis-report.md` - Comprehensive analysis - `repomix-analysis/repomix-heatmap.png` - Visual quality comparison **Documentation:** - `.claude/repomix-guide.md` - Usage guide (updated for single view) - `CLAUDE.md` - Memory System section (updated) - Implementation plans (updated with notes) ### Files Deleted Based on analysis, removed 6 redundant/suboptimal views: - `01-full-context.xml` (2.1M, 550K tokens) - Too large, poor token efficiency - `02-production-optimized.xml` (4.2M, 1.1M tokens) - Excessive, unusable - `04-backend-focused.xml` (403K, grade 6.6) - Too narrow, missing cross-component context - `05-frontend-focused.xml` (767K, grade 6.4) - Too narrow, missing cross-component context - `06-ultra-compressed.xml` (10M, 2.6M tokens) - Catastrophically large - `07-metadata-rich.xml` (849K, grade 8.3) - Redundant with #3 ### Benefits ✅ **Reduced repo size** - 19M → 1M (94% smaller) ✅ **Single high-quality reference** - Grade 8.8/10, best of all configurations ✅ **Optimal token efficiency** - 187K tokens fits comfortably in context windows ✅ **Simpler usage pattern** - No need to choose between 7 views ✅ **Comprehensive coverage** - All components, READMEs, types, manifests ✅ **Visual analysis included** - Heatmap shows why #3 is best ### Usage Example ``` "Claude, load the architecture view (repomix-analysis/03-architecture-only.xml) and help me understand how multi-repo support works in AgenticSessions." ``` ### Relationship to PR #359 - **PR #359** (merged): Created memory system documentation (context files, patterns, ADRs) - **PR #360** (this PR): Adds repomix reference view to complement the documentation Together they form the complete memory system for efficient Claude Code context loading. ### Test Plan - [x] Repomix view loads successfully in Claude Code - [x] Analysis report justifies single-view decision - [x] Heatmap visualizes quality comparison - [x] All documentation updated to reflect simplified approach - [x] Usage guide provides clear examples - [x] Repository size reduced by 94% 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude <noreply@anthropic.com>
## Summary Implements Phase 2 of the Amber workflow transparency initiative: automatic PR reviews using the memory system from PRs #359 and #360. ## Changes ### New Workflow: `.github/workflows/amber-auto-review.yml` **Automatic PR reviews with repository intelligence:** - **Trigger**: Automatic on PR open/synchronize - **Memory System**: Loads 7 files for comprehensive repository context - CLAUDE.md (master project instructions) - backend-development.md (Go backend, K8s patterns) - frontend-development.md (NextJS, Shadcn UI, React Query) - security-standards.md (Auth, RBAC, token handling) - k8s-client-usage.md (User token vs service account) - error-handling.md (Consistent error patterns) - react-query-usage.md (Data fetching patterns) - **Transparency**: Every review includes: - Link to workflow run (90-day log retention) - Collapsible section showing which memory files were loaded - Clear explanation of how Amber applies repository standards - **Comment Management**: Minimizes old review comments before posting new one ### Modified Workflow: `.github/workflows/claude-code-review.yml` **Changed from automatic to manual-only:** - **Before**: Triggered automatically on all PRs - **After**: Only triggers on `@claude` mentions in comments - **Reason**: Separate automatic reviews (Amber) from manual reviews (Claude) ## Three-Tier AI Integration This completes the separation of AI review types: 1. **`@claude`** (Lightweight) - Manual, quick interactions - No repository wrapping, fastest response - Use for: questions, exploration, explanations 2. **Automatic PR Reviews** (Amber-Wrapped) - NEW with this PR - Applies CLAUDE.md + memory system standards - Shows decision process via workflow logs - Trigger: Every PR open/sync (automatic) 3. **`@amber` mentions** (Repository-Aware) - Future Phase 3 - Planned: Manual `@amber` mentions for specific tasks - Will apply same memory system as automatic reviews ## Testing Tested on fork with PR: jeremyeder#33 After merge, every new PR will trigger `amber-auto-review.yml`. To verify immediately: 1. Merge this PR 2. The workflow should trigger on this PR itself (meta!) 3. Verify review comment appears with transparency section 4. Check workflow logs via the link in the review ## Design Decisions ### Why Direct File Loading (No Shell Script) **Rejected approach**: Shell script prompt builder using sed/grep/perl to extract CLAUDE.md sections **Chosen approach**: Direct file loading via Claude's Read tool - Simpler implementation - More maintainable (change memory files, workflow stays the same) - Leverages built-in Claude Code capabilities - No fragile shell script parsing ### Why Memory System Over CLAUDE.md Extraction The memory system (PRs #359, #360) provides: - Curated, focused context for specific domains - Easier to maintain and update - Better separation of concerns - Loadable on-demand for targeted work ## Impact **Users will see**: Every PR automatically gets a repository-aware code review showing: - Issues categorized by severity (Blocker/Critical/Major/Minor) - Positive highlights - Prioritized recommendations - Full transparency into AI decision-making **Developers will benefit from**: - Consistent application of project standards - Early detection of anti-patterns - Confidence in AI reviews (visible decision process) - Reduced review burden on human reviewers ## Related - **Builds on**: PRs #359, #360 (Memory System) - **Part of**: Amber Workflow Transparency Initiative - **Documentation**: Will be updated in follow-up PR --- 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
Summary
Implements a structured memory system to provide targeted, loadable context instead of relying solely on the comprehensive CLAUDE.md file.
Components Implemented
1. Context Files (
.claude/context/)backend-development.md- Go backend, K8s integration patternsfrontend-development.md- NextJS, Shadcn UI, React Query patternssecurity-standards.md- Auth, RBAC, token handling2. ADR Infrastructure (
docs/adr/)0001-kubernetes-native-architecture.md0002-user-token-authentication.md0003-multi-repo-support.md0004-go-backend-python-runner.md0005-nextjs-shadcn-react-query.md3. Repomix Usage Guide (
.claude/repomix-guide.md)4. Decision Log (
docs/decisions.md)5. Pattern Catalog (
.claude/patterns/)error-handling.md- Consistent error patterns (backend, operator, runner)k8s-client-usage.md- User token vs service account patternsreact-query-usage.md- Data fetching patterns (queries, mutations, caching)6. CLAUDE.md Updated
Value Proposition
Example Usage
Testing
Acceptance Criteria (from issue #357)
Closes #357
🤖 Generated with Claude Code