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