# 20 Use Cases for Nexus Memory

Real-world scenarios demonstrating how Nexus Memory transforms AI-assisted development.

---

## Table of Contents

### Enterprise Development
1. [Cross-Repository Code Pattern Learning](#1-cross-repository-code-pattern-learning)
2. [Architecture Decision Records (ADR) Memory](#2-architecture-decision-records-adr-memory)
3. [Bug Fix Knowledge Base](#3-bug-fix-knowledge-base)
4. [Code Review Learning Loop](#4-code-review-learning-loop)
5. [Dependency Upgrade History](#5-dependency-upgrade-history)

### Team Collaboration
6. [Shared Team Memory](#6-shared-team-memory)
7. [Onboarding Acceleration](#7-onboarding-acceleration)
8. [Meeting Decision Capture](#8-meeting-decision-capture)
9. [Sprint Retrospective Memory](#9-sprint-retrospective-memory)
10. [Cross-Team Knowledge Sharing](#10-cross-team-knowledge-sharing)

### AI Agent Orchestration
11. [Multi-Agent Context Sharing](#11-multi-agent-context-sharing)
12. [Long-Running Task Continuity](#12-long-running-task-continuity)
13. [User Preference Learning](#13-user-preference-learning)
14. [Project-Specific Conventions](#14-project-specific-conventions)
15. [Error Pattern Recognition](#15-error-pattern-recognition)

### Advanced Integration
16. [Git Commit Intelligence](#16-git-commit-intelligence)
17. [CI/CD Pipeline Memory](#17-cicd-pipeline-memory)
18. [Security Vulnerability Tracking](#18-security-vulnerability-tracking)
19. [Performance Regression History](#19-performance-regression-history)
20. [Documentation Drift Detection](#20-documentation-drift-detection)

---

## Enterprise Development

### 1. Cross-Repository Code Pattern Learning

**The Problem**
You implement an elegant solution in Project A, but when you need it in Project B three months later, you've forgotten the details. You end up re-solving the same problem or implementing an inferior solution.

**The Solution**
Store reusable patterns when you discover them:

```bash
# In Project A - when you solve it
echo '{
  "content": "Implemented retry logic with exponential backoff for flaky API calls. Pattern: initial delay 100ms, max 5 retries, factor 2, with jitter to prevent thundering herd. Used p-retry library with custom onFailedAttempt logging.",
  "event_type": "pattern"
}' | ~/.claude/hooks/store-memory.sh
```

```bash
# In Project B - months later
echo '{"query": "API retry exponential backoff"}' | ~/.claude/hooks/recall-memory.sh
```

**The Outcome**
Your AI instantly recalls the exact pattern, library choice, and configuration from Project A. Implementation time drops from hours of research to minutes of adaptation.

---

### 2. Architecture Decision Records (ADR) Memory

**The Problem**
Six months ago, your team decided to use PostgreSQL over MongoDB. Now a new team member asks "Why not MongoDB?" and nobody remembers the reasoning.

**The Solution**
Capture decisions with full context:

```bash
echo '{
  "content": "ADR-017: Chose PostgreSQL over MongoDB for user service. Reasons: (1) ACID compliance required for payment data, (2) Complex queries for reporting dashboard, (3) Team expertise in SQL, (4) Mature TypeORM support. Trade-offs: MongoDB would have simplified user profile schema evolution, but payment integrity was non-negotiable.",
  "event_type": "decision"
}' | ~/.claude/hooks/store-memory.sh
```

```bash
# When questioned later
echo '{"query": "why PostgreSQL not MongoDB user service"}' | ~/.claude/hooks/recall-memory.sh
```

**The Outcome**
Instant access to the original reasoning. New team members understand the "why" behind decisions, preventing revisiting settled debates and maintaining architectural consistency.

---

### 3. Bug Fix Knowledge Base

**The Problem**
You spend 4 hours debugging a cryptic Safari date parsing issue. Three months later, a similar issue appears, and you start from scratch because the original fix is lost in git history noise.

**The Solution**
Store fixes with searchable context:

```bash
echo '{
  "content": "Safari date parsing fails silently for ISO strings without explicit timezone. Fix: Always append T00:00:00 to date-only strings before parsing: new Date(dateStr + \"T00:00:00\"). Root cause: Safari strict ISO-8601 interpretation vs Chrome lenient parsing. Affects: iOS Safari, macOS Safari 14+.",
  "event_type": "fix"
}' | ~/.claude/hooks/store-memory.sh
```

```bash
# When the issue resurfaces
echo '{"query": "Safari date parsing NaN invalid"}' | ~/.claude/hooks/recall-memory.sh
```

**The Outcome**
Four hours of debugging becomes 30 seconds of recall. The fix includes root cause, affected browsers, and exact solution—not just a code snippet.

---

### 4. Code Review Learning Loop

**The Problem**
Code reviews contain valuable feedback, but lessons learned evaporate after the PR is merged. The same feedback appears in review after review.

**The Solution**
Store review feedback as learnings:

```bash
echo '{
  "content": "Code review feedback: Avoid using Array.prototype.reduce for simple accumulations. forEach or for-of is more readable and has better performance. Senior reviewer noted: reduce is appropriate for transformations, not mutations.",
  "event_type": "learning"
}' | ~/.claude/hooks/store-memory.sh
```

```bash
# Before submitting next PR
echo '{"query": "code review feedback patterns"}' | ~/.claude/hooks/recall-memory.sh
```

**The Outcome**
Your AI proactively applies past review feedback, reducing review cycles and accelerating your growth as a developer.

---

### 5. Dependency Upgrade History

**The Problem**
You upgrade React from 17 to 18 and things break. You fix them. Six months later, you upgrade another project and face the same issues again.

**The Solution**
Document upgrade experiences:

```bash
echo '{
  "content": "React 17→18 upgrade issues: (1) Strict Mode double-renders exposed side effects in useEffect - fix with AbortController, (2) createRoot replaces ReactDOM.render - update index.tsx, (3) Automatic batching changes state update behavior - no fix needed but test thoroughly, (4) TypeScript @types/react needs v18. Total time: 6 hours. Would have been 2 hours if documented.",
  "event_type": "learning"
}' | ~/.claude/hooks/store-memory.sh
```

```bash
# Next React 18 upgrade
echo '{"query": "React 18 upgrade migration issues"}' | ~/.claude/hooks/recall-memory.sh
```

**The Outcome**
The 6-hour upgrade becomes 1 hour with a pre-built checklist of expected issues and solutions.

---

## Team Collaboration

### 6. Shared Team Memory

**The Problem**
Tribal knowledge lives in the heads of senior developers. When they're on vacation or leave the company, critical institutional knowledge disappears.

**The Solution**
Build collective team memory:

```bash
# When senior dev explains something
echo '{
  "content": "CRITICAL: Never deploy to production on Fridays after 3pm PT. Historical context: Three major incidents in 2023 all occurred during Friday evening deploys. On-call rotation starts Monday, so Friday issues span entire weekend with skeleton crew.",
  "event_type": "context"
}' | ~/.claude/hooks/store-memory.sh
```

```bash
# Junior dev on Friday afternoon
echo '{"query": "deployment timing production best practices"}' | ~/.claude/hooks/recall-memory.sh
```

**The Outcome**
Institutional knowledge persists regardless of who's available. Team context transfers automatically to new members.

---

### 7. Onboarding Acceleration

**The Problem**
New team members take 3-6 months to become productive. Most of that time is spent understanding unwritten rules, hidden conventions, and historical context.

**The Solution**
Capture onboarding-relevant knowledge:

```bash
echo '{
  "content": "Project conventions: (1) All API routes in /src/routes/, (2) Database models in /src/models/ with Prisma, (3) Tests mirror source structure in /tests/, (4) Feature flags via LaunchDarkly - config in /src/config/flags.ts, (5) Never commit .env files - use .env.example as template.",
  "event_type": "context"
}' | ~/.claude/hooks/store-memory.sh
```

```bash
# New team member's first day
echo '{"query": "project structure conventions getting started"}' | ~/.claude/hooks/recall-memory.sh
```

**The Outcome**
New developers get instant access to project conventions, reducing onboarding time from months to weeks.

---

### 8. Meeting Decision Capture

**The Problem**
Technical decisions made in meetings are lost in chat history or forgotten entirely. Teams revisit the same discussions repeatedly.

**The Solution**
Store meeting decisions immediately:

```bash
echo '{
  "content": "Tech sync 2024-01-15: Decided to implement feature flags using LaunchDarkly instead of custom solution. Reasons: (1) Time to market - 2 weeks vs 8 weeks custom, (2) Targeting capabilities out of box, (3) Team already familiar from previous company. Action: @alice sets up LaunchDarkly account, @bob creates SDK wrapper.",
  "event_type": "decision"
}' | ~/.claude/hooks/store-memory.sh
```

```bash
# When someone asks "why LaunchDarkly?"
echo '{"query": "feature flags decision LaunchDarkly"}' | ~/.claude/hooks/recall-memory.sh
```

**The Outcome**
Meeting decisions are instantly recallable, complete with reasoning and action items.

---

### 9. Sprint Retrospective Memory

**The Problem**
The same issues surface in sprint retrospectives. "Deployments are too risky" appears quarter after quarter because action items aren't tracked beyond the sprint.

**The Solution**
Store retrospective learnings:

```bash
echo '{
  "content": "Sprint 23 Retro - Deployment Issues: Root cause identified as lack of staging environment parity with production. Actions: (1) Implement infrastructure-as-code for both envs, (2) Add staging smoke tests to CI, (3) Create deployment checklist. Owner: DevOps team. Target: Sprint 25.",
  "event_type": "learning"
}' | ~/.claude/hooks/store-memory.sh
```

```bash
# Next retro planning
echo '{"query": "deployment issues retrospective action items"}' | ~/.claude/hooks/recall-memory.sh
```

**The Outcome**
Recurring issues are tracked with context. Future retros can reference past learnings and measure progress.

---

### 10. Cross-Team Knowledge Sharing

**The Problem**
Team Alpha solves a complex authentication problem. Team Beta faces the same problem two months later and reinvents the wheel because knowledge doesn't cross team boundaries.

**The Solution**
Store cross-team relevant discoveries:

```bash
echo '{
  "content": "JWT refresh token rotation implementation: Used refresh token rotation with family tracking to detect token theft. When refresh token is reused, entire family is invalidated. Implementation in auth-service repo /src/auth/refresh-rotation.ts. Reduced account takeover incidents by 94%.",
  "event_type": "pattern"
}' | ~/.claude/hooks/store-memory.sh
```

```bash
# Team Beta's authentication work
echo '{"query": "JWT refresh token security implementation"}' | ~/.claude/hooks/recall-memory.sh
```

**The Outcome**
Teams benefit from organization-wide learnings without formal knowledge transfer processes.

---

## AI Agent Orchestration

### 11. Multi-Agent Context Sharing

**The Problem**
You use Claude Code for development and other AI tools for different tasks. Each starts from scratch with no shared context.

**The Solution**
Store context that any AI agent can access:

```bash
echo '{
  "content": "Project tech stack: Next.js 14 with App Router, TypeScript strict mode, Prisma ORM with PostgreSQL, TailwindCSS, Vercel deployment. Testing: Vitest for unit, Playwright for E2E. CI: GitHub Actions.",
  "event_type": "context"
}' | ~/.claude/hooks/store-memory.sh
```

```bash
# Any AI agent querying project context
echo '{"query": "project technology stack framework"}' | ~/.claude/hooks/recall-memory.sh
```

**The Outcome**
All AI tools share the same project context, eliminating repetitive explanations.

---

### 12. Long-Running Task Continuity

**The Problem**
You're 3 hours into a complex refactoring task when you need to stop. When you resume the next day, Claude Code has lost all context.

**The Solution**
Store progress checkpoints:

```bash
echo '{
  "content": "Refactoring auth system - checkpoint 3: Completed migration of /api/login and /api/register to new JWT structure. Remaining: /api/refresh, /api/logout, /api/password-reset. Current blocker: refresh rotation logic needs token family tracking. Next step: implement family table in Prisma schema.",
  "event_type": "context"
}' | ~/.claude/hooks/store-memory.sh
```

```bash
# Resuming next day
echo '{"query": "auth refactoring progress checkpoint"}' | ~/.claude/hooks/recall-memory.sh
```

**The Outcome**
Resume complex tasks exactly where you left off, even after days away from the project.

---

### 13. User Preference Learning

**The Problem**
You repeatedly tell Claude Code your preferences: "use functional components", "prefer named exports", "add TypeScript strict types". Every session starts fresh.

**The Solution**
Store preferences permanently:

```bash
echo '{
  "content": "User preferences: (1) Always use functional components with hooks, never class components, (2) Prefer named exports over default exports for better refactoring, (3) TypeScript strict mode with explicit return types on functions, (4) Use Prettier with single quotes and no semicolons, (5) Comments only for non-obvious logic, not for obvious code.",
  "event_type": "preference"
}' | ~/.claude/hooks/store-memory.sh
```

```bash
# Every new session
echo '{"query": "user coding preferences style"}' | ~/.claude/hooks/recall-memory.sh
```

**The Outcome**
Your AI adapts to your preferences automatically, producing code that matches your style from the first interaction.

---

### 14. Project-Specific Conventions

**The Problem**
Each project has unique conventions. Error handling in Project A differs from Project B, but Claude Code doesn't know the difference.

**The Solution**
Store project-specific conventions:

```bash
echo '{
  "content": "nexus-api project conventions: (1) All errors extend BaseError from /src/errors/base.ts, (2) Error codes follow NEXUS_[MODULE]_[TYPE] format, (3) API responses use ApiResponse wrapper from /src/types/api.ts, (4) Logging via Winston logger from /src/utils/logger.ts - never console.log, (5) All DB queries go through repository pattern in /src/repositories/.",
  "event_type": "context"
}' | ~/.claude/hooks/store-memory.sh
```

```bash
# Working on nexus-api
echo '{"query": "nexus-api error handling conventions"}' | ~/.claude/hooks/recall-memory.sh
```

**The Outcome**
Generated code follows project conventions automatically, reducing review feedback and maintaining consistency.

---

### 15. Error Pattern Recognition

**The Problem**
Your codebase has recurring error patterns. The same type of bug appears in different forms, but you diagnose each from scratch.

**The Solution**
Store error patterns for recognition:

```bash
echo '{
  "content": "Error pattern: \"Cannot read property X of undefined\" in async code usually means race condition in React useEffect. Common causes: (1) Component unmounted before async completes, (2) State accessed before initialization, (3) Missing dependency array causing stale closures. Fix pattern: useRef for mounted check, proper cleanup in useEffect return.",
  "event_type": "pattern"
}' | ~/.claude/hooks/store-memory.sh
```

```bash
# When similar error appears
echo '{"query": "undefined property async react error"}' | ~/.claude/hooks/recall-memory.sh
```

**The Outcome**
Your AI recognizes error patterns and suggests fixes based on your codebase's specific history.

---

## Advanced Integration

### 16. Git Commit Intelligence

**The Problem**
Git commit messages and code changes contain valuable context, but it's buried in history and disconnected from your AI's knowledge.

**The Solution**
Store commit context (future integration):

```bash
echo '{
  "content": "Commit abc123: Fixed race condition in user authentication. The session.save() was being called before token generation completed. Changed to await token generation before session save. Related to incident INC-2024-001. Test: /tests/auth/race-condition.test.ts",
  "event_type": "fix"
}' | ~/.claude/hooks/store-memory.sh
```

```bash
# Investigating similar issue
echo '{"query": "authentication race condition session"}' | ~/.claude/hooks/recall-memory.sh
```

**The Outcome**
Code changes are linked to reasoning, incidents, and tests—not just "what changed" but "why it changed."

---

### 17. CI/CD Pipeline Memory

**The Problem**
CI fails frequently for the same reasons. Each time, developers debug from scratch instead of recognizing common failure patterns.

**The Solution**
Store pipeline failure patterns:

```bash
echo '{
  "content": "CI failure pattern: E2E tests failing with ECONNREFUSED on database port. Root cause: Database container not ready before tests start. Fix: Add wait-for-it.sh script to docker-compose.test.yml with depends_on health checks. See /scripts/wait-for-db.sh.",
  "event_type": "fix"
}' | ~/.claude/hooks/store-memory.sh
```

```bash
# Next CI failure
echo '{"query": "CI database connection refused E2E tests"}' | ~/.claude/hooks/recall-memory.sh
```

**The Outcome**
Common CI failures are diagnosed instantly based on historical patterns.

---

### 18. Security Vulnerability Tracking

**The Problem**
A CVE is reported for a library you use. You patch it in one project but forget about the other three projects using the same library.

**The Solution**
Track security context:

```bash
echo '{
  "content": "CVE-2024-1234: Critical vulnerability in lodash < 4.17.21 allows prototype pollution. Affected projects: nexus-api (patched), user-service (patched), analytics-worker (TODO), legacy-admin (TODO). Patch: npm update lodash. Detection: npm audit.",
  "event_type": "context"
}' | ~/.claude/hooks/store-memory.sh
```

```bash
# Checking security status
echo '{"query": "lodash vulnerability CVE status projects"}' | ~/.claude/hooks/recall-memory.sh
```

**The Outcome**
Track vulnerability status across all projects, ensuring nothing falls through the cracks.

---

### 19. Performance Regression History

**The Problem**
Performance degrades over time. When you finally investigate, you don't know when it started or what changes might have caused it.

**The Solution**
Store performance context:

```bash
echo '{
  "content": "Performance baseline 2024-01-15: API p99 latency 120ms, database query avg 15ms, home page TTI 2.1s. Measured after removing N+1 query in /api/products endpoint. Previous baseline (2023-12-01): API p99 180ms. Improvement from adding Redis cache for product categories.",
  "event_type": "context"
}' | ~/.claude/hooks/store-memory.sh
```

```bash
# Investigating regression
echo '{"query": "API latency performance baseline history"}' | ~/.claude/hooks/recall-memory.sh
```

**The Outcome**
Performance history with context shows when regressions started and what previous optimizations were made.

---

### 20. Documentation Drift Detection

**The Problem**
Documentation says one thing, code does another. The API docs describe parameters that no longer exist because docs weren't updated with code changes.

**The Solution**
Store documentation-code relationships:

```bash
echo '{
  "content": "API documentation update needed: /api/users endpoint changed from POST body to query params for search in commit def456. Current docs in /docs/api/users.md still show POST body format. Also: rate limiting added (100 req/min) not documented.",
  "event_type": "context"
}' | ~/.claude/hooks/store-memory.sh
```

```bash
# Before release
echo '{"query": "documentation updates needed API changes"}' | ~/.claude/hooks/recall-memory.sh
```

**The Outcome**
Track documentation drift automatically, ensuring docs and code stay synchronized.

---

## Summary

These 20 use cases demonstrate how Nexus Memory transforms AI-assisted development:

| Category | Use Cases | Key Benefit |
|----------|-----------|-------------|
| **Enterprise Development** | 1-5 | Individual productivity |
| **Team Collaboration** | 6-10 | Institutional knowledge |
| **AI Agent Orchestration** | 11-15 | AI effectiveness |
| **Advanced Integration** | 16-20 | Operational excellence |

### Getting Started

1. **Install Nexus Memory** — See [Quick Start](../README.md#-quick-start)
2. **Start Small** — Store your first bug fix or decision
3. **Build Habits** — Store learnings as they happen
4. **Reap Rewards** — Recall knowledge when you need it

### What's Next?

- [Architecture Documentation](architecture.md) — Understand the system
- [API Reference](api-reference.md) — Integrate programmatically
- [Integration Guide](integration-guide.md) — Build custom integrations
- [Roadmap](../ROADMAP.md) — See what's coming
