Scenario
A user reports: "Login fails silently when the email has uppercase letters."
Initialize and Research
/kn-init
Then research the problem area with specific keywords:
/kn-research login email case sensitivity, email normalization, auth patterns
You: We have a bug — login fails when email has uppercase letters.
Search for related issues and patterns.
AI: [Calls search({ action: "search", query: "login email case sensitive" })]
Found related context:
- Memory: "Email normalization: always lowercase before DB lookup"
(from 3 weeks ago, when we fixed a similar issue in registration)
- Doc: @doc/patterns/auth — mentions bcrypt comparison
- Task-42: "Fix registration case sensitivity" (done)Memory advantage
The AI already has context from a similar fix. No re-investigation needed — it found the pattern in seconds.
Create a Bug Task
You: Create a task for this bug AI: ✓ Created task-9f3k: "Fix login case-sensitive email matching" AC-1: Login works with uppercase email input AC-2: Email is normalized to lowercase before DB query AC-3: Existing users with mixed-case emails can still login
Debug with Context
/kn-debug
AI: Debugging task-9f3k... → Memory says: "Email normalization pattern — lowercase before lookup" → Task-42 fixed this in registration: src/routes/register.ts → But src/routes/login.ts doesn't normalize! Root cause: login.ts compares email as-is against the DB, but registration lowercases it. Mismatch. Fix: Add email.toLowerCase() in login.ts before the DB query.
Implement the Fix
/kn-implement 9f3k
const user = await db.user.findUnique({
where: { email }
})const user = await db.user.findUnique({
where: { email: email.toLowerCase() }
})✓ AC-1: Login works with uppercase email ✓ ✓ AC-2: Email normalized before query ✓ ✓ AC-3: Existing users unaffected ✓ ✓ Task marked done
Save the Pattern
The AI captures this for future sessions:
AI: [Calls memory({ action: "add", layer: "project", ... })]
✓ Saved to project memory:
"Email handling: ALWAYS normalize to lowercase at the entry point
(both registration and login). DB stores lowercase only.
Related: task-42, task-9f3k"Next time someone reports a case-sensitivity issue, the AI already knows the pattern.
The Memory Advantage
| Without Memory | With Knowns Memory |
|---|---|
| Read the bug report | Read the bug report |
| Search the codebase manually | AI searches memory → finds pattern instantly |
| Re-discover the normalization pattern | AI knows exactly where to look |
| Fix the bug | Fix applied in seconds |
| Knowledge stays in your head | Pattern saved for the whole team |
Building Up Memory Over Time
Memory compounds. Each fix adds context for future sessions:
Session 1: "We use bcrypt for password hashing" Session 2: "Email normalization: always lowercase" Session 3: "Rate limiting: 5 attempts per 15 minutes" Session 4: AI knows your entire auth system
Memory Layers
| Layer | Use For | Example |
|---|---|---|
| Project | Repo-specific patterns | "Email always lowercase" |
| Global | Cross-project conventions | "Always validate input at boundary" |
Search before debugging
search({ query: "..." }) often finds the answer in memory. Use semantic search — "email case issue" finds "email normalization" even without exact keywords.
Save patterns proactively
Don't wait for extraction — save as you discover. Link related tasks so AI can trace the history.
What's next?
Explore the Memory System for the full reference, or try Semantic Search to see how AI finds context by meaning.
Tình huống
User báo: "Login fail im lặng khi email có chữ hoa."
Khởi tạo và Research
/kn-init
Sau đó research vấn đề với keywords cụ thể:
/kn-research login email case sensitivity, email normalization, auth patterns
Bạn: Có bug — login fail khi email có chữ hoa.
Tìm issues và patterns liên quan.
AI: [Gọi search({ action: "search", query: "login email case sensitive" })]
Tìm thấy context liên quan:
- Memory: "Email normalization: luôn lowercase trước DB lookup"
(từ 3 tuần trước, khi fix issue tương tự ở registration)
- Doc: @doc/patterns/auth — đề cập bcrypt comparison
- Task-42: "Fix registration case sensitivity" (done)Lợi thế Memory
AI đã có context từ fix tương tự. Không cần điều tra lại — tìm thấy pattern trong vài giây.
Tạo Bug Task
Bạn: Tạo task cho bug này AI: ✓ Đã tạo task-9f3k: "Fix login case-sensitive email matching" AC-1: Login hoạt động với email chữ hoa AC-2: Email được normalize thành lowercase trước DB query AC-3: Users hiện có với mixed-case emails vẫn login được
Debug với Context
/kn-debug
AI: Debugging task-9f3k... → Memory nói: "Email normalization pattern — lowercase trước lookup" → Task-42 đã fix ở registration: src/routes/register.ts → Nhưng src/routes/login.ts không normalize! Root cause: login.ts so sánh email nguyên bản với DB, nhưng registration lowercase nó. Mismatch. Fix: Thêm email.toLowerCase() trong login.ts trước DB query.
Implement Fix
/kn-implement 9f3k
const user = await db.user.findUnique({
where: { email }
})const user = await db.user.findUnique({
where: { email: email.toLowerCase() }
})✓ AC-1: Login hoạt động với email chữ hoa ✓ ✓ AC-2: Email normalized trước query ✓ ✓ AC-3: Users hiện có không bị ảnh hưởng ✓ ✓ Task marked done
Lưu Pattern
AI capture pattern cho sessions sau:
AI: [Gọi memory({ action: "add", layer: "project", ... })]
✓ Đã lưu vào project memory:
"Email handling: LUÔN normalize thành lowercase tại entry point
(cả registration và login). DB chỉ lưu lowercase.
Liên quan: task-42, task-9f3k"Lần sau ai báo case-sensitivity issue, AI đã biết pattern.
Lợi thế Memory
| Không có Memory | Với Knowns Memory |
|---|---|
| Đọc bug report | Đọc bug report |
| Tìm codebase thủ công | AI tìm memory → thấy pattern ngay |
| Phát hiện lại normalization pattern | AI biết chính xác nơi cần xem |
| Fix bug | Fix áp dụng trong vài giây |
| Knowledge ở trong đầu bạn | Pattern lưu cho cả team |
Memory tích lũy theo thời gian
Memory compound. Mỗi fix thêm context cho sessions sau:
Session 1: "Dùng bcrypt cho password hashing" Session 2: "Email normalization: luôn lowercase" Session 3: "Rate limiting: 5 attempts per 15 minutes" Session 4: AI biết toàn bộ auth system
Memory Layers
| Layer | Dùng cho | Ví dụ |
|---|---|---|
| Project | Patterns riêng repo | "Email luôn lowercase" |
| Global | Conventions cross-project | "Luôn validate input tại boundary" |
Tìm trước khi debug
search({ query: "..." }) thường tìm thấy câu trả lời trong memory. Dùng semantic search — "email case issue" tìm thấy "email normalization" dù không có keyword chính xác.
Lưu patterns chủ động
Đừng đợi extraction — lưu ngay khi phát hiện. Link related tasks để AI trace được history.
Tiếp theo?
Khám phá Memory System cho reference đầy đủ, hoặc thử Semantic Search để xem AI tìm context theo ý nghĩa.