Intermediate~20 minAI Workflows

Bug Triage with Memory

Use project memory and semantic search to diagnose and fix bugs faster across sessions.

MemorySearchDebug
/kn-init/kn-research/kn-debug/kn-implement
kn-init
kn-research
Create bug task
kn-debug
kn-implement
Save pattern

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
AI searches memory
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

Task created
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
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
src/routes/login.ts
Before
const user = await db.user.findUnique({
where: { email }
})
After
const user = await db.user.findUnique({
where: { email: email.toLowerCase() }
})
ACs verified
     ✓ 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:

Pattern saved
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 MemoryWith Knowns Memory
Read the bug reportRead the bug report
Search the codebase manuallyAI searches memory → finds pattern instantly
Re-discover the normalization patternAI knows exactly where to look
Fix the bugFix applied in seconds
Knowledge stays in your headPattern saved for the whole team

Building Up Memory Over Time

Memory compounds. Each fix adds context for future sessions:

Memory growth
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

LayerUse ForExample
ProjectRepo-specific patterns"Email always lowercase"
GlobalCross-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.