agentleFS
wittyreferencewittyreference/twilio-claude-plugin/skills/memory-systems/SKILL.md

memory-systems

Skill2 starsChanged 8 months agoMITView on GitHub

Twilio development skill: memory-systems

12 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use context-fundamentals, context-degradation and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • rohunvoraSkill

    context-fundamentals

    Understand the components, mechanics, and constraints of context in agent systems. Use when designing agent architectures, debugging context-related failures, or optimizing context usage.

    Also in 8 projects that use this

  • rohunvoraSkill

    context-degradation

    Recognize, diagnose, and mitigate patterns of context degradation in agent systems. Use when context grows large, agent performance degrades unexpectedly, or debugging agent failures.

    Also in 7 projects that use this

  • AbdullahMalik17Skill

    configuring-dapr-pubsub

    Configures Dapr pub/sub components for event-driven microservices with Kafka or Redis. Use when wiring agent-to-agent communication, setting up event subscriptions, or integrating Dapr sidecars. Covers component configuration, subscription patterns, publishing events, and Kubernetes deployment. NOT when using direct Kafka clients or non-Dapr messaging patterns.

    Also in 3 projects that use this

  • AbdullahMalik17Skill

    containerizing-applications

    Containerizes applications with Docker, docker-compose, and Helm charts. Use when creating Dockerfiles, docker-compose configurations, or Helm charts for Kubernetes. Includes Docker Hardened Images (95% fewer CVEs), multi-stage builds, and 15+ battle-tested gotchas.

    Also in 3 projects that use this

  • muratcankoylanSkill

    long-horizon-prompting

    This skill should be used when writing, enhancing, or evaluating the launch prompt for a long-running autonomous agent or a parallel multi-agent orchestration attacking a hard problem: pseudo-formal task briefs that define terms and an exact success predicate linguistically, enumerate non-counting outcomes, set persistence rules with explicit stop and return conditions and effort floors, manage a diverse portfolio of parallel approaches with an approach registry and blocked-route bookkeeping, and gate the return on adversarial audit. Route agent topology and coordination protocols to multi-agent-patterns, runtime control surfaces and loop governance to harness-engineering, evaluator and quality-gate construction to evaluation, judge design to advanced-evaluation, and compaction or memory mechanics to context-compression and memory-systems.

    Also in 3 projects that use this

  • +6 more from AbdullahMalik17
  • +1 more from rohunvora

The file

We split this skill into the rules it gives an agent

8 rules. 0 are common, 8 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 11 edited versions we read keep these.

  • 8

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    After completing a file

    line 68
  2. Distinctive:

    After tests pass/fail

    line 69
  3. Distinctive:

    After making an architectural decision

    line 70
  4. Distinctive:

    Before switching to a different task

    line 71
  5. Distinctive:

    When resuming after interruption

    line 72
  6. Distinctive:

    Use Twilio Sync Documents for state that needs to persist across webhook invocations or sessions:

    line 80
  7. Distinctive:

    Use Sync for complex state:

    line 194
  8. Distinctive:

    Use Twilio's built-in cookie support:

    line 215

“Common” is measured: kept by at least 6 in 10 of the 11 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

name: memory-systems description: State tracking and session memory management. Use when implementing cross-session persistence, managing Sync documents for state, or designing memory patterns for Twilio prototypes.

Memory Systems for Twilio Prototypes

This skill covers state tracking and memory management for Twilio development sessions.

Memory Types

Memory TypeScopeDurationStorage
SessionCurrent conversationUntil session endsIn-context
ProjectAcross sessionsPersistentFiles (CLAUDE.md, git)
Call/MessagePer interactionUntil call/message endsTwilio + logs
WorkflowPer feature/taskUntil task completeTodo list, commits

Session Memory (In-Context)

Track progress within the current Claude Code session.

What to Track

  • Current task/feature being built
  • Files created or modified
  • Tests written and their status
  • Key decisions made
  • Blockers encountered

Session Summary Format

Maintain a mental summary after each major action:

## Session: Voice IVR Feature

### Completed
- [x] Created functions/voice/ivr-menu.js
- [x] Added 3-option menu (sales, support, billing)
- [x] Unit tests passing (4/4)

### In Progress
- [ ] Integration test for full flow

### Decisions Made
- Using Polly.Amy voice for consistency
- DTMF-only input (no speech) for reliability
- Action URLs use relative paths

### Files Modified
- functions/voice/ivr-menu.js (new)
- functions/voice/ivr-handler.protected.js (new)
- __tests__/unit/voice/ivr-menu.test.js (new)

### Next Steps
- Write integration test
- Run /review for approval

When to Update Session Memory

  • After completing a file
  • After tests pass/fail
  • After making an architectural decision
  • Before switching to a different task
  • When resuming after interruption

Project Memory (Persistent)

Information that persists across sessions via files and Twilio Sync.

Twilio Sync for Agent State

Use Twilio Sync Documents for state that needs to persist across webhook invocations or sessions:

// Store agent state
const syncService = client.sync.v1.services(context.SYNC_SERVICE_SID);
await syncService.documents.create({
  uniqueName: `agent-state-${sessionId}`,
  data: {
    workflowPhase: 'dev',
    testsWritten: ['unit/voice.test.js'],
    decisions: ['Use Conference for warm transfer'],
    lastUpdated: new Date().toISOString()
  },
  ttl: 86400  // 24hr TTL for ephemeral state
});

// Retrieve state
const doc = await syncService.documents(`agent-state-${sessionId}`).fetch();
const state = doc.data;

When to use Sync vs files:

StorageUse When
Sync DocumentsWebhook state, cross-function sharing, real-time updates
Git/filesCode, configuration, permanent documentation
In-contextCurrent session only, will be lost on restart

CLAUDE.md as Project Memory

Root CLAUDE.md stores:

  • Project standards and conventions
  • Available commands and workflows
  • Environment variable requirements
  • Testing requirements

Subdirectory CLAUDE.md stores:

  • API-specific patterns
  • TwiML examples
  • Webhook parameter references
  • Common error codes

Git History as Memory

# Recent decisions
git log --oneline -10

# What changed for a feature
git log --oneline --grep="voice IVR"

# Files touched recently
git diff --name-only HEAD~5

Todo.md as Task Memory

# Project Todo

## In Progress
- [ ] Voice IVR menu

## Pending
- [ ] SMS keyword routing
- [ ] Verify 2FA flow

## Completed
- [x] Initial project setup
- [x] Voice incoming-call handler
- [x] Messaging incoming-sms handler

Call/Message State Memory

Track state across Twilio webhook invocations.

The Challenge

Twilio webhooks are stateless. Each request is independent:

Call 1: /voice/incoming-call
  ↓ (new HTTP request)
Call 2: /voice/gather-handler
  ↓ (new HTTP request)
Call 3: /voice/transfer

State Tracking Patterns

Pattern 1: URL Parameters

Pass state in TwiML action URLs:

// In incoming-call.js
twiml.gather({
  action: `/voice/menu-handler?attempt=1&caller=${encodeURIComponent(event.From)}`,
  numDigits: 1
});

// In menu-handler.js
const attempt = parseInt(event.attempt, 10) || 1;
const caller = event.caller;

if (attempt >= 3) {
  // Max retries reached
}

Pattern 2: Twilio Sync

Use Sync for complex state:

// Store state
const syncService = await client.sync.v1.services(context.SYNC_SERVICE_SID);
await syncService.documents.create({
  uniqueName: `call-${event.CallSid}`,
  data: {
    stage: 'menu',
    selections: [],
    startTime: new Date().toISOString()
  }
});

// Retrieve state
const doc = await syncService.documents(`call-${event.CallSid}`).fetch();
const callState = doc.data;

Pattern 3: Session Cookies

Use Twilio's built-in cookie support:

// Set cookie
const response = new Twilio.Response();
response.setCookie('menu_selection', '2');
response.appendHeader('Content-Type', 'text/xml');
response.setBody(twiml.toString());

// Read cookie (in next request)
const previousSelection = event.menu_selection;

State Logging for Debugging

Log state transitions for debugging:

// ABOUTME: Logs call state transitions for debugging.
// ABOUTME: Append-only log pattern for call flow tracing.

const logStateTransition = (callSid, fromState, toState, data) => {
  console.log(JSON.stringify({
    timestamp: new Date().toISOString(),
    callSid,
    transition: `${fromState} → ${toState}`,
    data
  }));
};

// Usage
logStateTransition(event.CallSid, 'menu', 'transfer', { digit: event.Digits });

Workflow Memory

Track progress through development workflows.

Git as Source of Truth

Git history is the primary activity log:

  • Commits capture what changed and why
  • todo.md captures session progress
  • learnings.md captures discoveries (capture → promote → clear)
  • DESIGN_DECISIONS.md captures architectural rationale
# What was done recently
git log --oneline -10

# What files changed for a feature
git log --name-only --oneline --grep="voice IVR"

# Diff since last tag/checkpoint
git diff HEAD~5 --name-only

Documentation Flywheel

The documentation flywheel uses file-based communication:

  • Hooks write suggestions to .claude/pending-actions.json
  • Agent reads file before commits
  • File is cleared after actions addressed
Hook runs → pending-actions.json → Agent reads → Takes action → Clears file

Workflow State Tracking

For multi-phase pipeline workflows, track phase completion:

## Workflow: new-feature "Voice IVR"

Status: IN_PROGRESS

### Phase History
| Phase | Agent | Status | Timestamp |
|-------|-------|--------|-----------|
| 1 | /architect | COMPLETE | 10:23 |
| 2 | /spec | COMPLETE | 10:35 |
| 3 | /test-gen | COMPLETE | 10:52 |
| 4 | /dev | IN_PROGRESS | 11:05 |

### Artifacts Created
- spec.md (phase 2)
- __tests__/unit/voice/ivr.test.js (phase 3)
- functions/voice/ivr.js (phase 4, in progress)

### Blockers
- None

### Decisions Log
- Phase 1: Chose sequential pipeline pattern
- Phase 2: DTMF-only, 3 options
- Phase 3: 6 test cases defined

Memory Anti-Patterns

Don't Store

  • Full webhook payloads (too large)
  • Passing test output (no longer relevant)
  • Resolved error messages
  • Old file versions (git handles this)

Don't Repeat

  • Information already in CLAUDE.md
  • Standard Twilio API signatures
  • Boilerplate patterns
  • Previously stated decisions

Don't Persist

  • Session-specific debugging info
  • Temporary workarounds
  • One-time configuration steps

Memory Retrieval Patterns

"What did we decide about X?"

# Search git commits
git log --all --oneline --grep="X"

# Search CLAUDE.md files
grep -r "X" --include="CLAUDE.md" .

"What files did we change for feature Y?"

# If committed
git log --name-only --oneline --grep="Y"

# If in progress
git status

"What was the error we fixed?"

# Check recent test changes
git diff HEAD~3 __tests__/

# Check Twilio logs — SID-targeted if you have one
# validate_debugger(resourceSid: "CA...") for a specific resource
# get_debugger_logs for time-window browsing

Implementation Checklist

For new Twilio features, track:

  • Requirements understood
  • Architecture decided
  • Tests written (failing)
  • Implementation complete (tests passing)
  • Code reviewed
  • Documentation updated
  • Committed to git

This checklist serves as memory of what's done and what remains.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.