docs: optimize CLAUDE.md with progressive disclosure#8
Merged
Conversation
- Reduce CLAUDE.md from 243 to 102 lines (58% reduction) - Reduce token usage from ~4000 to ~1500 (62% reduction) - Add context optimization research report - Extract rule docs to .claude/rules/ directory - Apply progressive disclosure: CLAUDE.md as index, load details on-demand Based on Anthropic's context engineering best practices: - Context rot: model precision degrades with token count - Instruction following degrades uniformly with more instructions - Keep CLAUDE.md concise and universally applicable Refs #7 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
hrygo
added a commit
that referenced
this pull request
Feb 5, 2026
- Reduce CLAUDE.md from 243 to 102 lines (58% reduction) - Reduce token usage from ~4000 to ~1500 (62% reduction) - Add context optimization research report - Extract rule docs to .claude/rules/ directory - Apply progressive disclosure: CLAUDE.md as index, load details on-demand Based on Anthropic's context engineering best practices: - Context rot: model precision degrades with token count - Instruction following degrades uniformly with more instructions - Keep CLAUDE.md concise and universally applicable Refs #7 Co-authored-by: Test User <test@example.com> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
hrygo
pushed a commit
that referenced
this pull request
Feb 7, 2026
This optimization eliminates unnecessary vector search for list/filter queries. **Problem**: All memo queries were routed through semantic vector search, including simple list queries like "有什么笔记" which should use SQL. **Solution**: Added a 4-layer query intent classifier: - Layer 1: List intent (0ms) → "有什么笔记" → SQL list - Layer 2: Filter intent (0ms) → "今天的笔记" → SQL filter - Layer 3: Keyword intent (0ms) → "Python" → BM25 - Layer 4: Semantic default → "如何部署" → Vector **New retrieval strategies**: - `memo_list_only`: Pure SQL list (fastest, ~10ms) - `memo_filter_only`: SQL with time filter - `memo_bm25_only`: BM25 keyword search (no embedding) - `memo_semantic_only`: Vector search (existing) **Performance impact**: | Query | Before | After | |-------|--------|-------| | "有什么笔记" | ~500ms (Embedding) | ~10ms (SQL) | Refs #8 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
hrygo
pushed a commit
that referenced
this pull request
Feb 7, 2026
This optimization eliminates unnecessary vector search for list/filter queries. **Problem**: All memo queries were routed through semantic vector search, including simple list queries like "有什么笔记" which should use SQL. **Solution**: Added a 4-layer query intent classifier: - Layer 1: List intent (0ms) → "有什么笔记" → SQL list - Layer 2: Filter intent (0ms) → "今天的笔记" → SQL filter - Layer 3: Keyword intent (0ms) → "Python" → BM25 - Layer 4: Semantic default → "如何部署" → Vector **New retrieval strategies**: - `memo_list_only`: Pure SQL list (fastest, ~10ms) - `memo_filter_only`: SQL with time filter - `memo_bm25_only`: BM25 keyword search (no embedding) - `memo_semantic_only`: Vector search (existing) **Performance impact**: | Query | Before | After | |-------|--------|-------| | "有什么笔记" | ~500ms (Embedding) | ~10ms (SQL) | Refs #8 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
hrygo
added a commit
that referenced
this pull request
Feb 7, 2026
… routing improvements (#120) * refactor(chat): simplify branching to block number display - Replace branch path (A, B, C...) with sequential block numbers (1, 2, 3...) - Update BranchIndicator to show BlockNumberBadge with Hash icon - Remove branch creation UI from BlockEditDialog - Remove all branch-related props from BlockHeader and UnifiedMessageBlock - Keep database fields (parent_block_id, branch_path) reserved but unused Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(hooks): remove invalid --silent flag from pnpm lint:fix The lint:fix script doesn't accept --silent parameter, causing pre-commit hook to fail even when lint passes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(chat): remove optimistic update to eliminate block creation flicker The optimistic update in useCreateBlock was causing a visual flicker where an empty pending block would momentarily appear before being replaced by the actual block from the server. Changed to wait for server response before updating the cache, which provides a smoother UX without the intermediate empty state. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(chat): align ErrorSection timeline icon position with other sections Fixed inconsistent ErrorSection UI where the error icon was not properly positioned on the timeline. Now uses the same `absolute -left-[2rem] top-0` positioning as other sections (Thinking, ToolCall, Answer). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(agent): handle empty query in memo_search for "list all" requests When user asks "有什么笔记" (what notes do you have), the LLM generates an empty query parameter, causing tool execution failure. Changes: 1. memo_search tool: Treat empty query as "search all" (using "*" wildcard) 2. MemoParrot prompt: Add explicit examples for searching all notes - query: "*" for listing all memos - query: "Python" for keyword search This allows natural "list all" queries to work without errors. Fixes: ai.agent.event error "query cannot be empty" Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(chat): fix PR review issues - Add missing i18n keys for block number display - Fix handleEditConfirm to log instead of silently discarding edits - Add localStorage error logging in CompactToolCall - Remove unused props (blockId, conversationId) from BlockEditDialog - Update useBlockEditDialog hook signature - Add comprehensive test coverage for BranchIndicator - Add edge case tests for blockNumber (0, negative, large) - Fix test selectors and remove unused imports Refs #3 (PR review fixes) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat(ai): add intelligent memo query routing (SQL vs Vector) This optimization eliminates unnecessary vector search for list/filter queries. **Problem**: All memo queries were routed through semantic vector search, including simple list queries like "有什么笔记" which should use SQL. **Solution**: Added a 4-layer query intent classifier: - Layer 1: List intent (0ms) → "有什么笔记" → SQL list - Layer 2: Filter intent (0ms) → "今天的笔记" → SQL filter - Layer 3: Keyword intent (0ms) → "Python" → BM25 - Layer 4: Semantic default → "如何部署" → Vector **New retrieval strategies**: - `memo_list_only`: Pure SQL list (fastest, ~10ms) - `memo_filter_only`: SQL with time filter - `memo_bm25_only`: BM25 keyword search (no embedding) - `memo_semantic_only`: Vector search (existing) **Performance impact**: | Query | Before | After | |-------|--------|-------| | "有什么笔记" | ~500ms (Embedding) | ~10ms (SQL) | Refs #8 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(tools): use unicode property class for Chinese characters in regex Replace `\u4e00-\u9fff` with `\p{Han}` for proper Unicode character class matching in Go regexp. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(chat): prevent block creation flicker by predicting roundNumber - Use predicted roundNumber (existing blocks count + 1) for optimistic block - Remove refetchBlocks() call after streaming completion - The streaming handler already updates block via optimistic updates This eliminates the flicker caused by: 1. Optimistic block with roundNumber=0 appearing briefly 2. Then being replaced by backend data with correct roundNumber 3. Then refetchBlocks() triggering another re-render Now the optimistic block appears with the correct roundNumber immediately, and no additional refetch is needed since all data is already streamed. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(ui): remove animation effects during block creation Remove fade-in, slide-in, and pulse animations that were causing visual "flicker" effects during streaming block creation. Changes: - Remove animate-in fade-in slide-in-from-top-1 from tool details expansion - Remove animate-in fade-in from thinking content expansion - Remove animate-pulse from running tool timeline node - Remove animate-pulse from streaming answer timeline node - Remove animate-in fade-in from pending state initialization - Remove animate-block-pulse from streaming block container Retain animate-spin for Loader2 components (spinner icons). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(ui): remove block breathing animation during creation Remove animate-block-pulse from streaming block container to prevent visual flicker/breathing effect during block creation. Other animations (fade-in, slide-in, pulse for timeline nodes) are preserved as they provide meaningful UI feedback. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(ai): optimize memo query routing with intent classification Implement intelligent query routing to use SQL for list/filter queries instead of forcing all queries through vector search. Changes: - Add MemoQueryClassifier with 4-layer intent classification: * IntentList: List all memos ("有什么笔记", "*", etc.) * IntentFilter: Time/tag filters ("今天的笔记", "#work") * IntentKeyword: Simple keywords (BM25 search) * IntentSemantic: Complex semantic queries (vector search) - Add 3 new retrieval strategies in AdaptiveRetriever: * memo_list_only: Pure SQL list (fastest) * memo_filter_only: SQL with time filter using CEL * memo_bm25_only: BM25 keyword search without embedding - Fix semantic query classification by reordering checks: * Check semantic patterns before short query pattern * Prevents "如何部署服务" from being classified as keyword - Add comprehensive unit tests for query classifier - Remove duplicate time range extraction code - Add timeout error handling with DeadlineExceeded check Refs #119 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(chat): remove placeholder text from thinking events Fix the issue where thinking placeholder text like "正在思考..." was displayed as actual content in the Block's thinking section. Root cause: Backend was sending hardcoded Chinese text as thinking event content, which frontend couldn't distinguish from real content. Changes: - MemoParrot: Use "ai.states.thinking" key instead of "正在思考..." - AmazingParrot: Use "ai.states.thinking" key instead of "正在分析您的需求..." - UnifiedMessageBlock: Dynamically build placeholder filter list from i18n translations to catch all translated placeholders This ensures placeholder texts are filtered out from display, showing only genuine thinking content. Ref: Frontend already had translateThinkingSteps() to handle i18n keys. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(chat): show thinking section even when content is placeholder only Fix the issue where thinking section was not displayed when the only thinking content was placeholder text (e.g., "ai.states.thinking"). The problem was that the display condition checked `allThinkingContent.length > 0`, but `allThinkingContent` is filtered to exclude placeholders, causing the section to be hidden even when `thinkingSteps` existed. Changes: - Show thinking section when `thinkingSteps.length > 0` OR `streamingPhase === "thinking"` - Only allow expand/collapse toggle when there is real content - Only show expanded content view when there is real content This ensures the thinking section is always visible when thinking events exist, while the expandable content area only shows non-placeholder content. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * refactor(chat): remove edit button from AI chat footer Remove the edit button and related edit functionality from the AI chat Block footer to simplify the UI. Changes: - BlockFooter.tsx: Remove edit button, Pencil icon, and onEdit prop - UnifiedMessageBlock.tsx: Remove onEdit from props and component - ChatMessages.tsx: Remove edit dialog, handleEdit, and handleEditConfirm - Update test file to remove onEdit prop This simplifies the footer UX by removing the unimplemented edit feature. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * perf(chat): optimize block streaming UI performance Implement comprehensive performance optimizations for block streaming UI to achieve smooth, ChatGPT-like typing animation and real-time progress display. P0 optimizations: - Replace O(n) array traversal with O(1) Map lookup in useAIQueries.ts - Switch from StreamingText to StreamingMarkdown for sentence-level rendering - Leverage React 18 automatic batching instead of dual cache updates P1 optimizations: - Merge 6 useEffect hooks into 2 unified scroll handlers in ChatMessages.tsx - Add smart caching for messageBlocks conversion to avoid re-processing history - Reduce scroll trigger threshold from 50 to 15 characters for better responsiveness Type safety improvements: - Fix BlockBodyProps.parrotId type from string to ParrotAgentType enum - Use enum constants (ParrotAgentType.GEEK/EVOLUTION) instead of string literals - Fix BlockEvent to use 'meta' instead of 'metadata' field i18n fixes: - Add missing 'block_number' translation key to en.json and zh-Hant.json - Remove duplicate 'block_number' key in zh-Hant.json Refs #119 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: 黄飞虹 <aaronwong1989@gmail.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概述
基于 Anthropic 官方文档和社区最佳实践的深度调研,优化 CLAUDE.md 采用渐进式披露策略。
变更内容
调研来源
关联 Issue
Resolves #7
检查清单