# Detect Patterns

> Finds repeated ordered sequences across multiple sessions in BehavioralTrace data. Produces PatternReport artifacts with confidence scores. Use during Soulcatcher pattern detection, when analyzing cross-session behavior, or when the user asks what workflows they repeat.

- Skill: `justtyashh/detect-patterns` (Agent Skill)
- Install (CLI): `npx skillmds@latest add justtyashh/detect-patterns`
- Raw SKILL.md: https://api.skillmd.com/api/skills/justtyashh/detect-patterns/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: JusttYashh (https://skillmd.com/u/justtyashh)
- Updated: 2026-09-22
- Page: https://skillmd.com/skills/justtyashh/detect-patterns

---


# Detect Patterns

Find recurring **sequences**, not preferences.

Read schemas in [../soulcatcher/reference.md](../soulcatcher/reference.md).

**Worked example:** [learned-skills/examples/pipeline-output/pattern-report.md](../../learned-skills/examples/pipeline-output/pattern-report.md)

## Input

- Set of BehavioralTrace artifacts (minimum **3 relevant sessions**)
- Optional: problem_class filter from user

## Process

1. Group traces by `problem_class`
2. For each group, extract ordered event sequences (generalize event descriptions to step labels)
3. Find subsequences that repeat across sessions with stable order
4. Score using confidence rules in reference.md
5. Collect counterexamples (sessions where core steps were skipped)
6. Rank patterns by confidence

## Step Label Generalization

Convert literal events to reusable labels:

| Literal event | Step label |
|---------------|------------|
| "Listed two candidate approaches" | generate_candidates |
| "Wrote pros and cons" | weigh_pros_cons |
| "Searched for failure cases" | search_counterexamples |
| "Identified strongest downside" | surface_strongest_downside |
| "Committed after risks explicit" | decide_after_risks_explicit |

## Anti-Patterns (do not report)

- Single-session habits
- Tool or language preferences ("uses Python", "uses grep")
- Formatting or style quirks
- Steps that appear in different orders across sessions (unless marked optional)

## Output Format

```markdown
# PatternReport: {pattern_id}

```yaml
pattern_id: adversarial-decision-sequence
problem_class: decision-analysis
sequence:
  - frame_decision
  - generate_candidates
  - weigh_pros_cons
  - search_counterexamples
  - surface_strongest_downside
  - decide_after_risks_explicit
occurrences: 12
sessions_total: 15
sessions_matched:
  - decision-analysis-01
  - decision-analysis-02
  # ...
confidence: 87
counterexamples:
  - session_id: decision-analysis-13
    deviation: Skipped counterexample search; decided on pros/cons alone
  - session_id: decision-analysis-14
    deviation: Committed before surfacing strongest downside
position_stability: high
context_diversity:
  - product tradeoff
  - architecture choice
  - vendor selection
  - hire decision
  - research conclusion
```
```

## Handoff

Pass top PatternReport(s) to infer-procedure. If no pattern meets minimum threshold (3 sessions, confidence ≥ 60), report honestly and stop.

