**Status:** π Agent Guideline | **Module:** ritual | **Part of:** Agent Brain Pattern detection and habit tracking. The agent should watch for repeated behaviors and store them as `pattern` entries.
Installs into .claude/skills of the current project.
Are you the author of Ritual?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/modbender-ritual)
# Ritual Memory π
**Status:** π Agent Guideline | **Module:** ritual | **Part of:** Agent Brain
Pattern detection and habit tracking. The agent should watch for repeated behaviors and store them as `pattern` entries.
## What It Does
Guides the agent to notice repeated actions and store them as `pattern` entries. Ritual does NOT run automatically β the agent must manually check for patterns using the `similar` command.
## Detection
The agent uses the `similar` command to find related entries:
### After Storing a Procedure or Preference
```bash
# After storing, check for similar entries
./scripts/memory.sh similar "<content>" 0.10
# If 3+ SIMILAR_ENTRIES of same type β create a pattern
./scripts/memory.sh add pattern "User always asks for examples when learning" \
inferred "learning,style,examples"
```
This is a **manual** step the agent should perform β it is not automatic.
### What the `similar` Command Does
- Uses TF-IDF with cosine similarity (no external libraries)
- Filters stopwords for meaningful comparison
- Returns scored results above threshold (default 0.10)
- Works across sessions β the engine handles persistence
### What Counts as "Similar"
- TF-IDF similarity score >= 0.10 (configurable threshold)
- Same or overlapping tags
- Same type of action (procedure/preference)
## Anti-Pattern Detection (Automatic)
The ONE automatic detection that exists: when the `correct` command is called and 3+ corrections share the same tag, the system suggests creating an anti-pattern entry. This IS implemented in code.
```bash
# After 3 corrections with tag "code.database":
# System prints: ANTI_PATTERN_DETECTED: tag 'code.database' has 3 corrections
# Suggests: add anti-pattern "Avoid inferring code.database - ask explicitly" inferred "code.database,caution"
```
## Pattern Storage
```bash
# When the agent detects a pattern (manual):
./scripts/memory.sh add pattern "User always asks for examples when learning new concepts" \
inferred "learning,style,examples"
```
Pattern entries have:
- `source: "inferred"` (not user-stated)
- `confidence: "uncertain"` (until confirmed)
- Tags linking to the topic area
## Pattern Lifecycle
```
Behavior observed once β stored as fact/preference/procedure
Agent runs similar, finds 3+ matches β agent creates pattern entry (uncertain)
User confirms pattern β ./scripts/memory.sh update <id> confidence sure
User denies pattern β ./scripts/memory.sh supersede <id> <new_id>
Pattern unused 60+ days β decayed via standard decay
```
## What Ritual Does NOT Do
- Auto-detect patterns (agent must manually run `similar`)
- Execute automated workflows
- Call external APIs or services
- Run scheduled tasks
## Integration
- **Archive**: Agent reads `similar` results to detect patterns manually
- **Gauge**: Patterns start as UNCERTAIN, upgrade on confirmation