/context
Search memories by keyword and show relevant context
> /plugin marketplace add SukinShetty/Nemp-memory > /plugin install nemp@nemp-memory
How it fires
How this command gets triggered: by you, by Claude, or both.
- Fires itselfClaude auto-loads it when your prompt matches the work.
- You can call itInvoke it directly when you want it.
- Slash command
/context
Context preview
What this command does when you run it.
Search memories by keyword and show relevant context
Command definition
context.mddescription: "Search memories by keyword and show relevant context"
argument-hint: "<search-query>"
/nemp:context
Find and display memories relevant to a search query using smart keyword expansion.
Usage
/nemp:context auth # Find memories related to authentication
/nemp:context database # Find database-related memories
/nemp:context api # Find API-related memories
/nemp:context style # Find styling/CSS memories
/nemp:context test # Find testing-related memories
Instructions
1. Get the Search Query
Extract the search term from the user's command argument.
If no argument provided, show help:
Nemp Context Search
Usage: /nemp:context <search-term>
Examples:
/nemp:context auth - Find authentication memories
/nemp:context database - Find database memories
/nemp:context api - Find API memories
/nemp:context style - Find styling/CSS memories
/nemp:context test - Find testing memories
Smart search expands your query to related terms!
2. Expand Keywords Using Smart Mappings
Based on the search term, expand to related keywords:
KEYWORD MAPPINGS:
auth, login, authentication:
→ auth, authentication, login, session, jwt, oauth, nextauth, clerk,
supabase-auth, passport, token, credentials, signin, signup, logout
database, db:
→ database, db, postgres, postgresql, mysql, sqlite, mongo, mongodb,
prisma, drizzle, mongoose, sequelize, knex, typeorm, schema, migration
api, endpoint:
→ api, endpoint, route, rest, graphql, trpc, fetch, axios, request,
response, http, webhook, cors, middleware
style, css, styling:
→ style, css, tailwind, emotion, styled-components, chakra, mantine,
theme, design, scss, sass, less, classname, styling
test, testing:
→ test, testing, jest, vitest, playwright, cypress, unit, integration,
e2e, mock, fixture, assertion, coverage, spec
state, store:
→ state, store, redux, zustand, jotai, recoil, context, provider,
reducer, action, selector, persist
deploy, hosting:
→ deploy, deployment, hosting, vercel, netlify, aws, docker, kubernetes,
ci, cd, pipeline, github-actions, build
config, env, environment:
→ config, configuration, env, environment, dotenv, settings, options,
variables, secrets, keys
error, debug:
→ error, debug, debugging, exception, catch, try, logging, sentry,
bugsnag, stack, trace, console
types, typescript:
→ types, typescript, interface, type, generic, zod, yup, schema,
validation, typing3. Search Both Project and Global Memories
**Read memory files:**
Project memories: .nemp/memories.json
Global memories: ~/.nemp/memories.json
Memory format:
{
"key-name": "memory value content",
"another-key": "another value"
}Use the Read tool to load both files. Handle missing files gracefully.
4. Find Matching Memories
For each memory entry, perform case-insensitive matching:
For each (key, value) in memories:
- Check if KEY contains any expanded keyword
- Check if VALUE contains any expanded keyword
- If match found, add to results with match type
**Match Priority:** 1. **Key exact match** - Key equals search term 2. **Key contains** - Key contains search term or expanded keyword 3. **Value contains** - Value contains search term or expanded keyword
4b. Update Vitality for All Returned Memories
For each memory that matches and will be displayed to the user, update its vitality counters:
1. If the memory lacks cortex fields, initialize with defaults first:
- `type`: `"fact"`
- `confidence`: `{"score": 0.65, "source": "agent-inferred", "reason": "Pre-cortex memory"}`
- `vitality`: all counters set to 0, `score`: 50, `state`: "active", `trend`: "stable", `last_read`: null, `decay_rate`: 0.01
- `links`: `{"goals": [], "conflicts": [], "supersedes": null, "superseded_by": null, "causal": []}`
2. For each matched memory, update:
vitality.reads += 1
vitality.reads_7d += 1
vitality.reads_30d += 1
vitality.last_read = <current ISO-8601 timestamp>
3. Recalculate `vitality.score` using the formula:
vitality = (
(reads_7d × 15) +
(reads_30d × 3) +
(foresight_load_ratio × 20) +
(agent_reference_ratio × 25) +
(update_frequency × 10) +
(goal_link_active × 15) -
(correction_events × 10) -
(days_since_last_read × decay_rate)
)
clamped to 0-100Where:
- `foresight_load_ratio` = foresight_loads / (foresight_loads + foresight_skips), default 0 if both are 0
- `agent_reference_ratio` = agent_references / reads, default 0 if reads is 0
- `update_frequency` = update_count / max(1, days_since_created)
- `goal_link_active` = 1 if links.goals has any active goal, else 0
4. Set `vitality.state` based on score:
- 80-100: `"thriving"`
- 50-79: `"active"`
- 20-49: `"fading"`
- 1-19: `"dormant"`
- 0: `"extinct"`
5. Write ALL updated memories back to memories.json in **one write operation** (do not write per-memory).
**Log the operation:**
echo "[$(date -u +%Y-%m-%dT%H:%M:%SZ)] CONTEXT_READ agent=${CLAUDE_AGENT_NAME:-main} query=<query> matched=<n>" >> .nemp/access.log5. Display Results
**When matches found:**
Context Search: "auth"
Expanded to: auth, authentication, login, session, jwt, oauth, nextauth...
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
PROJECT MEMORIES
auth-config [KEY MATCH]
────────────────────────
JWT authentication with refresh tokens. Access token expires
in 15 minutes, refresh token in 7 days...
api-routes [VALUE MATCH]
────────────────────────
POST /api/login - User authentication
POST /api/register - New user signup...
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
GLOBAL MEMORIES
security-best-practices [VALUE MATCH]
────────────────────────────────────
Always use bcrypt for password hashing. Implement rate
limiting on auth endpoin
Read more
description: "Search memories by keyword and show relevant context" argument-hint: "<search-query>"
/nemp:context
Find and display memories relevant to a search query using smart keyword expansion.
Usage
/nemp:context auth # Find memories related to authentication /nemp:context database # Find database-related memories /nemp:context api # Find API-related memories /nemp:context style # Find styling/CSS memories /nemp:context test # Find testing-related memories
Instructions
1. Get the Search Query
Extract the search term from the user's command argument.
If no argument provided, show help:
Nemp Context Search Usage: /nemp:context <search-term> Examples: /nemp:context auth - Find authentication memories /nemp:context database - Find database memories /nemp:context api - Find API memories /nemp:context style - Find styling/CSS memories /nemp:context test - Find testing memories Smart search expands your query to related terms!
2. Expand Keywords Using Smart Mappings
Based on the search term, expand to related keywords:
KEYWORD MAPPINGS:
auth, login, authentication:
→ auth, authentication, login, session, jwt, oauth, nextauth, clerk,
supabase-auth, passport, token, credentials, signin, signup, logout
database, db:
→ database, db, postgres, postgresql, mysql, sqlite, mongo, mongodb,
prisma, drizzle, mongoose, sequelize, knex, typeorm, schema, migration
api, endpoint:
→ api, endpoint, route, rest, graphql, trpc, fetch, axios, request,
response, http, webhook, cors, middleware
style, css, styling:
→ style, css, tailwind, emotion, styled-components, chakra, mantine,
theme, design, scss, sass, less, classname, styling
test, testing:
→ test, testing, jest, vitest, playwright, cypress, unit, integration,
e2e, mock, fixture, assertion, coverage, spec
state, store:
→ state, store, redux, zustand, jotai, recoil, context, provider,
reducer, action, selector, persist
deploy, hosting:
→ deploy, deployment, hosting, vercel, netlify, aws, docker, kubernetes,
ci, cd, pipeline, github-actions, build
config, env, environment:
→ config, configuration, env, environment, dotenv, settings, options,
variables, secrets, keys
error, debug:
→ error, debug, debugging, exception, catch, try, logging, sentry,
bugsnag, stack, trace, console
types, typescript:
→ types, typescript, interface, type, generic, zod, yup, schema,
validation, typing3. Search Both Project and Global Memories
**Read memory files:**
Project memories: .nemp/memories.json
Global memories: ~/.nemp/memories.json
Memory format:
{
"key-name": "memory value content",
"another-key": "another value"
}Use the Read tool to load both files. Handle missing files gracefully.
4. Find Matching Memories
For each memory entry, perform case-insensitive matching:
For each (key, value) in memories: - Check if KEY contains any expanded keyword - Check if VALUE contains any expanded keyword - If match found, add to results with match type
**Match Priority:** 1. **Key exact match** - Key equals search term 2. **Key contains** - Key contains search term or expanded keyword 3. **Value contains** - Value contains search term or expanded keyword
4b. Update Vitality for All Returned Memories
For each memory that matches and will be displayed to the user, update its vitality counters:
1. If the memory lacks cortex fields, initialize with defaults first:
- `type`: `"fact"`
- `confidence`: `{"score": 0.65, "source": "agent-inferred", "reason": "Pre-cortex memory"}`
- `vitality`: all counters set to 0, `score`: 50, `state`: "active", `trend`: "stable", `last_read`: null, `decay_rate`: 0.01
- `links`: `{"goals": [], "conflicts": [], "supersedes": null, "superseded_by": null, "causal": []}`
2. For each matched memory, update:
vitality.reads += 1 vitality.reads_7d += 1 vitality.reads_30d += 1 vitality.last_read = <current ISO-8601 timestamp>
3. Recalculate `vitality.score` using the formula:
vitality = (
(reads_7d × 15) +
(reads_30d × 3) +
(foresight_load_ratio × 20) +
(agent_reference_ratio × 25) +
(update_frequency × 10) +
(goal_link_active × 15) -
(correction_events × 10) -
(days_since_last_read × decay_rate)
)
clamped to 0-100Where:
- `foresight_load_ratio` = foresight_loads / (foresight_loads + foresight_skips), default 0 if both are 0
- `agent_reference_ratio` = agent_references / reads, default 0 if reads is 0
- `update_frequency` = update_count / max(1, days_since_created)
- `goal_link_active` = 1 if links.goals has any active goal, else 0
4. Set `vitality.state` based on score:
- 80-100: `"thriving"`
- 50-79: `"active"`
- 20-49: `"fading"`
- 1-19: `"dormant"`
- 0: `"extinct"`
5. Write ALL updated memories back to memories.json in **one write operation** (do not write per-memory).
**Log the operation:**
echo "[$(date -u +%Y-%m-%dT%H:%M:%SZ)] CONTEXT_READ agent=${CLAUDE_AGENT_NAME:-main} query=<query> matched=<n>" >> .nemp/access.log5. Display Results
**When matches found:**
Context Search: "auth" Expanded to: auth, authentication, login, session, jwt, oauth, nextauth... ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ PROJECT MEMORIES auth-config [KEY MATCH] ──────────────────────── JWT authentication with refresh tokens. Access token expires in 15 minutes, refresh token in 7 days... api-routes [VALUE MATCH] ──────────────────────── POST /api/login - User authentication POST /api/register - New user signup... ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ GLOBAL MEMORIES security-best-practices [VALUE MATCH] ──────────────────────────────────── Always use bcrypt for password hashing. Implement rate limiting on auth endpoin
Nemp - The memory plugin for Claude Code that remembers everything.
Other commands on nemp.
auto-export
Experimental: Enable or disable automatic cross-provider memory export

