Skip to content
Back to skills

Mama Context

ASecurity

Always-on background context injection from MAMA memory. Automatically surfaces relevant decisions when you work on code, without explicit invocation.

  • 4 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added September 12, 2026
ai-agentsgobashnodetestingperformance

Works with

  • claude code
  • mcp

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned September 12, 2026

npx -y skills add aibot88/sec_skill_store --skill mama-context --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Mama Context?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Mama Context
[![Security: A β€” Skills Directory](https://www.skillsdirectory.com/api/skills/aibot88-mama-context/badge)](https://www.skillsdirectory.com/skills/aibot88-mama-context)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: mama-context
description: Always-on background context injection from MAMA memory. Automatically surfaces relevant decisions when you work on code, without explicit invocation.
---

# MAMA Context - Auto-Injection Skill

## Overview

This skill provides **automatic background context injection** using MAMA's hook system. It runs silently and surfaces relevant past decisions via the UserPromptSubmit hook (~150ms latency with HTTP embedding server).

**Philosophy:** Gentle hints, not intrusive walls of text. Claude sees topic + time, decides if relevant.

---

## How It Works

The skill uses a **multi-hook system** for comprehensive context injection:

**UserPromptSubmit Hook** (active, ~150ms β€” no plugin-side script; handled by Claude Code host)

- Triggers: On every user message submission
- Purpose: Inject relevant decisions as context before Claude responds
- Latency: ~150ms (HTTP embedding server keeps model in memory)
- Token budget: 40 tokens (teaser format)

**SessionStart Hook** (`scripts/sessionstart-hook.js`)

- Triggers: Once per session
- Purpose: Initialize MAMA, pre-warm embedding model
- Timeout: 15s

**PreToolUse Hook** (`scripts/pretooluse-hook.js`) - **disabled** (script retained)

- Previously: Injected contracts before Edit/Write operations
- Status: Disabled for performance. Script retained for future use.

**PostToolUse Hook** (`scripts/posttooluse-hook.js`) - **disabled** (script retained)

- Previously: Tracked code changes, suggested decision saves
- Status: Disabled for performance. Script retained for future use.

**PreCompact Hook** (`scripts/precompact-hook.js`)

- Triggers: Before context compaction
- Purpose: Preserve unsaved decisions in compacted context
- Timeout: 10s

---

## Teaser Format (40 tokens)

```text
πŸ’‘ MAMA: 2 related
   β€’ authentication_strategy (85%, 3 days ago)
   β€’ mesh_detail (78%, 1 week ago)
   /mama:search <topic> for details
```

**Why teaser?**

- Hooks fire on user messages (UserPromptSubmit) β†’ Must be lightweight
- Claude infers relevance from topic + similarity + time
- Full details available via `/mama:search` if needed
- Avoids token bloat (250 tokens β†’ 40 tokens)

---

## Status Transparency

Every injection shows current tier status:

**Tier 1 (Full Features):**

```text
πŸ” System Status: βœ… Full Features Active (Tier 1)
   - Vector Search: βœ… ON (Transformers.js, 3ms latency)
   - Search Quality: HIGH (80% accuracy)
```

**Tier 2 (Degraded):**

```text
πŸ” System Status: ⚠️ DEGRADED MODE (Tier 2)
   - Vector Search: ❌ OFF (embedding model failed)
   - Search Quality: BASIC (40% accuracy, exact match only)

⚠️ Fix: Check embedding model installation
```

---

## Configuration

**Disable Skill:**

```bash
# Environment variable
export MAMA_DISABLE_HOOKS=true

# Or in config file (~/.mama/config.json)
{
  "disable_hooks": true
}
```

**Adjust Thresholds:**

```json
{
  "similarity_threshold": 0.7,
  "token_budget": 40,
  "rate_limit_ms": 1000
}
```

> **Note:** `similarity_threshold: 0.7` applies to explicit searches (`/mama:search`). The disabled `pretooluse-hook.js` uses a looser `SIMILARITY_THRESHOLD = 0.6` (kept from its original contract-injection design). The active UserPromptSubmit hook delegates search to the MCP server, which uses its own default threshold. Hook thresholds are intentionally separate from the config value shown above.

---

## When Claude Should Use This

βœ… **Automatic (no action needed):**

- Context appears when relevant decisions exist
- Claude notices hints and can request details
- User sees transparent status (Tier 1/2)

❌ **Don't explicitly invoke this skill:**

- It's always-on (background process)
- Hooks handle triggering automatically
- Use `/mama:search` for explicit lookups

---

## Technical Details

**Hook Integration:**

- UserPromptSubmit: Active (~150ms, no plugin-side script; handled by Claude Code host via MCP)
- SessionStart: `scripts/sessionstart-hook.js` (initialization)
- PreToolUse: `scripts/pretooluse-hook.js` (disabled, script retained)
- PostToolUse: `scripts/posttooluse-hook.js` (disabled, script retained)
- PreCompact: `scripts/precompact-hook.js` (decision preservation)

**Performance:**

- Hook latency: ~150ms (HTTP embedding server, model stays in memory)
- Cold start: ~1500ms (embedding model initialization, first session only)
- Warm: ~50ms (HTTP embedding request)
- Timeout: 1800ms (graceful degradation if exceeded)

**Search Algorithm:**

- Vector search: Transformers.js (3ms embedding)
- Hybrid scoring: 20% recency + 50% importance + 30% semantic
- Graph expansion: Follows supersedes edges
- Recency boost: Gaussian decay (30-day half-life)

---

## Acceptance Criteria Mapping

- βœ… AC1: Declared in plugin.json, references hook outputs
- βœ… AC2: Similarity thresholds (70%) + token budgets (40 teaser / 250 full)
- βœ… AC3: Disable via config (MAMA_DISABLE_HOOKS)
- βœ… AC4: Status indicator (Tier 1/2, accuracy, fix instructions)
- βœ… AC5: Smoke test - fires during normal coding session

---

## Example Output

**User edits a file related to authentication:**

**Skill injects (via UserPromptSubmit hook):**

```text
πŸ’‘ MAMA: 1 related
   β€’ auth_strategy (90%, 2 days ago)
   /mama:search auth_strategy for full decision

πŸ” System Status: βœ… Full Features Active (Tier 1)
```

**Claude sees the hint and can:**

1. Ignore (if not relevant)
2. Suggest `/mama:search auth_strategy` to user
3. Continue with general advice

---

## For Developers

**Testing:**

```bash
# Test SessionStart hook (the only testable standalone hook)
node packages/claude-code-plugin/scripts/sessionstart-hook.js

# UserPromptSubmit hook is triggered automatically by Claude Code
# on every user message β€” no manual invocation needed.
```

**Architecture:**

```text
User submits prompt
    ↓
UserPromptSubmit Hook (~150ms, 1800ms timeout)
    ↓
Decision search (generate embedding, search, score)
    ↓
Context injection to Claude (40-token teaser)
    ↓
Claude sees context
```

---

## Key Principles

1. **Lightweight:** 40 tokens teaser format
2. **Transparent:** Always show tier status and latency
3. **Non-intrusive:** Hints, not walls of text
4. **Opt-out:** User control via config (MAMA_DISABLE_HOOKS)
5. **Graceful degradation:** Tier 2 fallback if embeddings unavailable
6. **Multi-hook system:** UserPromptSubmit (active) + SessionStart + PreCompact + PreToolUse/PostToolUse (disabled)

---

## Related

- Story M3.2 (this skill)
- Story M2.2 (PreToolUse hook β€” disabled, scripts retained)
- Story M2.4 (Transparency banner)
- Architecture: `docs/MAMA-ARCHITECTURE.md` (Decision 4 - Hook Implementation)

Files in this skill

  • SKILL.md6.5 KB
  • source.json651 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.