Context-First Skill
Core Principle: Understand the design intent before taking action.
Project Detection: Automatically identifies project root via git repository location.
When This Skill Activates
This skill should activate for ANY task involving project features or functionality:
Implementation Tasks ✅
- Implement/add/modify/fix functionality
- Write new code or refactor existing code
- Debug issues related to features
- Examples: "实现 OAuth 登录", "修复同步问题", "添加消息功能"
Analysis & Discussion Tasks ✅
- Answer "how does X work?"
- Explain "why did we design it this way?"
- Discuss "can we add Y feature?"
- Architecture analysis
- Examples: "OAuth 流程是怎么设计的?", "为什么用 Logto?"
Documentation Tasks ✅
- Update feature documentation
- Write user guides or technical specs
- Create or revise design documents
- Examples: "更新 OAuth 文档", "写一个同步功能的说明"
Decision & Planning Tasks ✅
- Evaluate proposed changes
- Assess feature feasibility
- Review compatibility with existing design
- Examples: "可以添加第三方登录吗?", "这个改动合适吗?"
Core Workflow
Step 1: Identify Feature Domain
Extract feature keywords from the user's request. Common domains:
- Authentication: OAuth, auth, login, sign in, Logto, authentication, 登录, 认证
- Synchronization: sync, synchronization, Happy Server, upstream, 同步
- Messaging: message, messaging, chat, conversation, inbox, 消息, 聊天
- Terminal: terminal, command, shell, CLI, 终端, 命令
- Workspace: zen mode, boxes, workspace, session, 工作区
- Architecture: architecture, system design, components, modules, 架构
- Product: features, requirements, product, 产品, 需求
Step 2: Search Design Documents
ALWAYS check these locations in this order:
docs/design/ - Primary design documents (most important!)
core-user-experience-v2.md - Main UX design (most features described here)
architecture.md - System architecture and component design
prd.md - Product requirements and feature list
white-paper.md - Project vision and philosophy
docs/implementation/ - Technical implementation plans
- May reference design decisions
- Contains specific setup guides
docs/research/ - Background research and analysis
- Understanding why certain technologies were chosen
docs/verification/ - Test scenarios and acceptance criteria
- Reveals requirements and expected behavior
Search Strategy:
Use Grep to search for keywords across documentation:
# Search by feature keyword in design docs
grep -r "oauth\|authentication\|logto" docs/design/
grep -r "sync\|synchronization\|happy.*server" docs/design/
grep -r "messaging\|chat\|conversation" docs/design/
grep -r "terminal\|command\|shell" docs/design/
grep -r "zen\|boxes\|workspace" docs/design/
# If design docs don't have it, search implementation
grep -r "keyword" docs/implementation/
# Search across all docs as fallback
grep -r "keyword" docs/
Step 3: Load and Read Relevant Documents
Priority loading order:
- Read the most relevant
docs/design/*.md first (especially core-user-experience-v2.md)
- Read related
docs/implementation/*.md for technical details
- Read
docs/research/*.md for background context if needed
Important: Use the Read tool to actually read the documents. Don't assume you know the content.
Step 4: Summarize Context
Before proceeding, present the loaded context to the user:
Template:
🔍 Context Loaded
I found and read these design documents:
- docs/design/core-user-experience-v2.md (Section: [relevant section])
- docs/implementation/[relevant-file].md
📋 Key Design Decisions:
- [Decision 1]
- [Decision 2]
- [Constraint or principle]
✅ Ready to proceed with this context in mind.
Step 5: Proceed with Context
Only AFTER loading and summarizing the design context, proceed with the actual task.
Feature → Document Quick Reference
Use this mapping to quickly identify which documents to read:
| User Mentions |
Primary Documents to Load |
| OAuth, authentication, login, Logto, 登录, 认证 |
design/core-user-experience-v2.md (Authentication section)implementation/logto-web-oauth-setup.mdresearch/authentication-system-analysis.md |
| Sync, synchronization, Happy Server, upstream, 同步 |
design/architecture.md (Sync section)design/core-user-experience-v2.md (Sync section)research/authentication-system-analysis.md |
| Message, messaging, chat, conversation, inbox, 消息 |
design/core-user-experience-v2.md (Messaging section)design/prd.md |
| Terminal, command, shell, CLI, 终端 |
design/core-user-experience-v2.md (Terminal section)design/prd.md |
| Zen mode, boxes, workspace, session, 工作区 |
design/core-user-experience-v2.md (Workspace section)design/prd.md |
| Architecture, system, components, modules, 架构 |
design/architecture.mddesign/core-user-experience-v2.md |
| Product, features, requirements, vision, 产品 |
design/prd.mddesign/white-paper.mddesign/core-user-experience-v2.md |
Tip: When in doubt, core-user-experience-v2.md is usually the best starting point as it covers most features.
If No Design Document Found
If you cannot find relevant design documentation:
⚠️ Alert the user clearly:
⚠️ Design Context Missing
I couldn't find design documentation for [feature/topic].
This means:
- No documented design decisions exist yet
- Risk of misalignment with project vision
- May need to create design doc first
Options:
1. Create design document first (recommended) - use three-doc-method skill
2. Proceed with general project principles from CLAUDE.md
3. Ask you for design guidance
What would you like to do?
Do NOT proceed with implementation without explicit user approval
Suggest creating documentation first if this is a new feature
Best Practices
- ✅ Always read, don't assume - Even if you think you know the design, read the docs
- ✅ Read the full section - Don't just skim, understand the complete context
- ✅ Check multiple documents - Design decisions may be spread across files
- ✅ Summarize what you learned - Make the context visible to the user
- ✅ When uncertain, read more - Better to over-load context than miss key details
Examples
Example 1: Implementation Task
User: "实现 OAuth 登录的'记住我'功能"
Skill Response:
🔍 Context-First: Loading OAuth design context...
Found relevant documents:
- docs/design/core-user-experience-v2.md
- docs/implementation/logto-web-oauth-setup.md
Let me read these to understand the current OAuth design...
[After reading]
📋 Key Context:
- Current OAuth flow uses Logto with full-page redirect (not popup)
- Authentication state managed via Logto SDK hooks
- Design principle: "Zero Modification" - prefer Logto's built-in features
- User tokens stored in localStorage via Logto SDK
For "记住我" functionality, I should:
- Check if Logto SDK has built-in "remember me" support
- Maintain the full-page redirect flow
- Not modify upstream Logto code
Ready to proceed with implementation following these constraints.
Example 2: Discussion Task
User: "Happy Server 的同步机制是怎么设计的?"
Skill Response:
🔍 Context-First: Loading sync architecture context...
Reading:
- docs/design/architecture.md
- docs/design/core-user-experience-v2.md (Sync section)
[After reading]
📋 Sync Architecture Summary:
[Provides detailed summary from the design docs]
Does this answer your question? Would you like me to dive deeper into any aspect?
Example 3: Missing Context
User: "添加语音通话功能"
Skill Response:
🔍 Context-First: Searching for voice call design...
⚠️ Design Context Missing
I searched docs/design/ and couldn't find design documentation for voice call functionality.
This is a significant new feature that needs design documentation first.
Recommendation: Use the `three-doc-method` skill to create:
- Design document (why voice calls, what's the UX)
- Implementation plan (how to build it)
- Verification document (how to test it)
Should I help you create these documents first?
Benefits of Context-First Approach
- ✅ Prevents rework - Understand requirements before coding
- ✅ Maintains consistency - Align with existing design decisions
- ✅ Respects constraints - Avoid violating architectural principles
- ✅ Better decisions - Context enables informed choices
- ✅ Faster development - No backtracking due to misunderstanding
- ✅ Knowledge transfer - Spread understanding of design decisions
Related Skills
- three-doc-method - Create design documents for new features (use when context is missing)
- e2e-test-runner - Run tests after implementation (verification phase)
Troubleshooting
Q: Skill activates too often / too rarely?
A: Check the description triggers in the YAML frontmatter. Adjust keywords as needed.
Q: Can't find relevant documents?
A: Use find-docs.sh script or search more broadly with grep -r "keyword" docs/
Q: Found too many documents?
A: Prioritize docs/design/ and specifically core-user-experience-v2.md first.
Q: Documents are outdated?
A: Alert the user and suggest updating docs before proceeding with the task.
1---2name: context-first3description: Load relevant design documents and project context before working on any task. Use when user asks about features, requests implementation, discusses functionality, analyzes architecture, updates documentation, or mentions specific components like OAuth, authentication, Logto, sync, Happy Server, messaging, chat, terminal, command, zen mode, boxes, workspace. Ensures all work is grounded in documented design decisions. Prevents assumptions and misaligned solutions by loading context first.4---5
6# Context-First Skill
7
8**Core Principle:** Understand the design intent before taking action.
9
10**Project Detection:** Automatically identifies project root via git repository location.
11
12## When This Skill Activates
13
14This skill should activate for ANY task involving project features or functionality:
15
16### Implementation Tasks ✅
17- Implement/add/modify/fix functionality
18- Write new code or refactor existing code
19- Debug issues related to features
20- Examples: "实现 OAuth 登录", "修复同步问题", "添加消息功能"
21
22### Analysis & Discussion Tasks ✅
23- Answer "how does X work?"
24- Explain "why did we design it this way?"
25- Discuss "can we add Y feature?"
26- Architecture analysis
27- Examples: "OAuth 流程是怎么设计的?", "为什么用 Logto?"
28
29### Documentation Tasks ✅
30- Update feature documentation
31- Write user guides or technical specs
32- Create or revise design documents
33- Examples: "更新 OAuth 文档", "写一个同步功能的说明"
34
35### Decision & Planning Tasks ✅
36- Evaluate proposed changes
37- Assess feature feasibility
38- Review compatibility with existing design
39- Examples: "可以添加第三方登录吗?", "这个改动合适吗?"
40
41## Core Workflow
42
43### Step 1: Identify Feature Domain
44
45Extract feature keywords from the user's request. Common domains:
46
47- **Authentication**: OAuth, auth, login, sign in, Logto, authentication, 登录, 认证
48- **Synchronization**: sync, synchronization, Happy Server, upstream, 同步
49- **Messaging**: message, messaging, chat, conversation, inbox, 消息, 聊天
50- **Terminal**: terminal, command, shell, CLI, 终端, 命令
51- **Workspace**: zen mode, boxes, workspace, session, 工作区
52- **Architecture**: architecture, system design, components, modules, 架构
53- **Product**: features, requirements, product, 产品, 需求
54
55### Step 2: Search Design Documents
56
57**ALWAYS check these locations in this order:**
58
591. **`docs/design/`** - Primary design documents (most important!)
60 - `core-user-experience-v2.md` - Main UX design (most features described here)
61 - `architecture.md` - System architecture and component design
62 - `prd.md` - Product requirements and feature list
63 - `white-paper.md` - Project vision and philosophy
64
652. **`docs/implementation/`** - Technical implementation plans
66 - May reference design decisions
67 - Contains specific setup guides
68
693. **`docs/research/`** - Background research and analysis
70 - Understanding why certain technologies were chosen
71
724. **`docs/verification/`** - Test scenarios and acceptance criteria
73 - Reveals requirements and expected behavior
74
75**Search Strategy:**
76
77Use Grep to search for keywords across documentation:
78
79```bash
80# Search by feature keyword in design docs
81grep -r "oauth\|authentication\|logto" docs/design/
82grep -r "sync\|synchronization\|happy.*server" docs/design/
83grep -r "messaging\|chat\|conversation" docs/design/
84grep -r "terminal\|command\|shell" docs/design/
85grep -r "zen\|boxes\|workspace" docs/design/
86
87# If design docs don't have it, search implementation
88grep -r "keyword" docs/implementation/
89
90# Search across all docs as fallback
91grep -r "keyword" docs/
92```
93
94### Step 3: Load and Read Relevant Documents
95
96**Priority loading order:**
971. Read the most relevant `docs/design/*.md` first (especially `core-user-experience-v2.md`)
982. Read related `docs/implementation/*.md` for technical details
993. Read `docs/research/*.md` for background context if needed
100
101**Important:** Use the Read tool to actually read the documents. Don't assume you know the content.
102
103### Step 4: Summarize Context
104
105Before proceeding, present the loaded context to the user:
106
107**Template:**
108```
109🔍 Context Loaded
110
111I found and read these design documents:
112- docs/design/core-user-experience-v2.md (Section: [relevant section])
113- docs/implementation/[relevant-file].md
114
115📋 Key Design Decisions:
116- [Decision 1]
117- [Decision 2]
118- [Constraint or principle]
119
120✅ Ready to proceed with this context in mind.
121```
122
123### Step 5: Proceed with Context
124
125Only AFTER loading and summarizing the design context, proceed with the actual task.
126
127## Feature → Document Quick Reference
128
129Use this mapping to quickly identify which documents to read:
130
131| User Mentions | Primary Documents to Load |
132|--------------|---------------------------|
133| OAuth, authentication, login, Logto, 登录, 认证 | `design/core-user-experience-v2.md` (Authentication section)<br>`implementation/logto-web-oauth-setup.md`<br>`research/authentication-system-analysis.md` |
134| Sync, synchronization, Happy Server, upstream, 同步 | `design/architecture.md` (Sync section)<br>`design/core-user-experience-v2.md` (Sync section)<br>`research/authentication-system-analysis.md` |
135| Message, messaging, chat, conversation, inbox, 消息 | `design/core-user-experience-v2.md` (Messaging section)<br>`design/prd.md` |
136| Terminal, command, shell, CLI, 终端 | `design/core-user-experience-v2.md` (Terminal section)<br>`design/prd.md` |
137| Zen mode, boxes, workspace, session, 工作区 | `design/core-user-experience-v2.md` (Workspace section)<br>`design/prd.md` |
138| Architecture, system, components, modules, 架构 | `design/architecture.md`<br>`design/core-user-experience-v2.md` |
139| Product, features, requirements, vision, 产品 | `design/prd.md`<br>`design/white-paper.md`<br>`design/core-user-experience-v2.md` |
140
141**Tip:** When in doubt, `core-user-experience-v2.md` is usually the best starting point as it covers most features.
142
143## If No Design Document Found
144
145If you cannot find relevant design documentation:
146
1471. ⚠️ **Alert the user clearly:**
148 ```
149 ⚠️ Design Context Missing
150
151 I couldn't find design documentation for [feature/topic].
152
153 This means:
154 - No documented design decisions exist yet
155 - Risk of misalignment with project vision
156 - May need to create design doc first
157
158 Options:
159 1. Create design document first (recommended) - use three-doc-method skill
160 2. Proceed with general project principles from CLAUDE.md
161 3. Ask you for design guidance
162
163 What would you like to do?
164 ```
165
1662. **Do NOT proceed with implementation** without explicit user approval
167
1683. **Suggest creating documentation first** if this is a new feature
169
170## Best Practices
171
1721. ✅ **Always read, don't assume** - Even if you think you know the design, read the docs
1732. ✅ **Read the full section** - Don't just skim, understand the complete context
1743. ✅ **Check multiple documents** - Design decisions may be spread across files
1754. ✅ **Summarize what you learned** - Make the context visible to the user
1765. ✅ **When uncertain, read more** - Better to over-load context than miss key details
177
178## Examples
179
180### Example 1: Implementation Task
181
182**User:** "实现 OAuth 登录的'记住我'功能"
183
184**Skill Response:**
185```
186🔍 Context-First: Loading OAuth design context...
187
188Found relevant documents:
189- docs/design/core-user-experience-v2.md
190- docs/implementation/logto-web-oauth-setup.md
191
192Let me read these to understand the current OAuth design...
193
194[After reading]
195
196📋 Key Context:
197- Current OAuth flow uses Logto with full-page redirect (not popup)
198- Authentication state managed via Logto SDK hooks
199- Design principle: "Zero Modification" - prefer Logto's built-in features
200- User tokens stored in localStorage via Logto SDK
201
202For "记住我" functionality, I should:
203- Check if Logto SDK has built-in "remember me" support
204- Maintain the full-page redirect flow
205- Not modify upstream Logto code
206
207Ready to proceed with implementation following these constraints.
208```
209
210### Example 2: Discussion Task
211
212**User:** "Happy Server 的同步机制是怎么设计的?"
213
214**Skill Response:**
215```
216🔍 Context-First: Loading sync architecture context...
217
218Reading:
219- docs/design/architecture.md
220- docs/design/core-user-experience-v2.md (Sync section)
221
222[After reading]
223
224📋 Sync Architecture Summary:
225
226[Provides detailed summary from the design docs]
227
228Does this answer your question? Would you like me to dive deeper into any aspect?
229```
230
231### Example 3: Missing Context
232
233**User:** "添加语音通话功能"
234
235**Skill Response:**
236```
237🔍 Context-First: Searching for voice call design...
238
239⚠️ Design Context Missing
240
241I searched docs/design/ and couldn't find design documentation for voice call functionality.
242
243This is a significant new feature that needs design documentation first.
244
245Recommendation: Use the `three-doc-method` skill to create:
246- Design document (why voice calls, what's the UX)
247- Implementation plan (how to build it)
248- Verification document (how to test it)
249
250Should I help you create these documents first?
251```
252
253## Benefits of Context-First Approach
254
255- ✅ **Prevents rework** - Understand requirements before coding
256- ✅ **Maintains consistency** - Align with existing design decisions
257- ✅ **Respects constraints** - Avoid violating architectural principles
258- ✅ **Better decisions** - Context enables informed choices
259- ✅ **Faster development** - No backtracking due to misunderstanding
260- ✅ **Knowledge transfer** - Spread understanding of design decisions
261
262## Related Skills
263
264- **three-doc-method** - Create design documents for new features (use when context is missing)
265- **e2e-test-runner** - Run tests after implementation (verification phase)
266
267## Troubleshooting
268
269**Q: Skill activates too often / too rarely?**
270A: Check the description triggers in the YAML frontmatter. Adjust keywords as needed.
271
272**Q: Can't find relevant documents?**
273A: Use `find-docs.sh` script or search more broadly with `grep -r "keyword" docs/`
274
275**Q: Found too many documents?**
276A: Prioritize `docs/design/` and specifically `core-user-experience-v2.md` first.
277
278**Q: Documents are outdated?**
279A: Alert the user and suggest updating docs before proceeding with the task.