Ctx journal enrich all

From ActiveMemory/ctx · View interactive version

Ctx journal enrich all is an AI agent skill from the GitHub repository ActiveMemory/ctx. Full journal pipeline: import unimported sessions, then batch-enrich all unenriched entries. Use when the user says 'process the journal' or to catch up on the backlog.

How to use this skill

Skill file

Full journal pipeline: import if needed, then batch-enrich.

When to Use

When NOT to Use

Process

Step 0: Import If Needed

Before enriching, check whether there are unimported sessions. If

the journal directory has no .md files at all, or if there are

.jsonl session files newer than the newest journal entry, import

them first.

CTX_PATH=$(ctx system bootstrap -q)
JOURNAL_DIR="$CTX_PATH/journal"

# Check if any .md files exist
md_count=$(ls "$JOURNAL_DIR"/*.md 2>/dev/null | wc -l)

if [ "$md_count" -eq 0 ]; then
  echo "No journal entries found: importing all sessions."
  ctx journal import --all --yes
else
  # Compare newest .md mtime against .jsonl files
  newest_md=$(stat -c %Y $(ls -t "$JOURNAL_DIR"/*.md | head -1))
  unimported=$(find ~/.claude/projects -name "*.jsonl" -newermt @${newest_md} 2>/dev/null | wc -l)
  if [ "$unimported" -gt 0 ]; then
    echo "$unimported unimported session(s) found: importing first."
    ctx journal import --all --yes
  fi
fi

Report how many sessions were imported (or "none needed") before

moving to enrichment.

Step 1: Find Unenriched Entries

List all journal entries that lack enrichment using the state file:

# List .md files in journal dir and check state
CTX_PATH=$(ctx system bootstrap -q)
for f in "$CTX_PATH/journal/"*.md; do
  name=$(basename "$f")
  ctx system mark-journal --check "$name" enriched || echo "$f"
done

Or read .state.json in the journal directory directly and list

entries without an enriched date set.

Fallback: Detect Enrichment from Frontmatter

If mark-journal --check is unavailable (no state file, command

fails), fall back to frontmatter inspection. An entry is considered

already enriched if its YAML frontmatter contains both type

and outcome fields: these are set exclusively by enrichment, never

by import.

Do NOT use title or date to detect enrichment: those are always

present from import. The enrichment-only fields are:

| Field | Set by |

|----------------|----------------|

| title | Import |

| date | Import |

| time | Import |

| model | Import |

| tokens_in | Import |

| tokens_out | Import |

| session_id | Import |

| project | Import |

| type | Enrichment |

| outcome | Enrichment |

| topics | Enrichment |

| technologies | Enrichment |

| summary | Enrichment |

If all entries already have enrichment recorded, report that and stop.

Step 2: Filter Out Noise

Skip entries that are not worth enriching:

locked date OR the frontmatter contains locked: true. Never

modify locked files: neither metadata nor body. Check via:

ctx system mark-journal --check <filename> locked

or look for locked: true in the YAML frontmatter.

only auto-complete fragments. Check with:

```bash

wc -l <file>

```

etc. Enrich only the first part; continuation parts inherit

the frontmatter topic.

Report how many entries will be processed and how many were

filtered out.

Step 3: Process Each Entry

For each entry, read the conversation and extract:

  1. Title: a short descriptive title for the session
  2. Type: feature, bugfix, refactor, exploration, debugging,

or documentation

  1. Outcome: completed, partial, abandoned, or blocked
  2. Topics: 2-5 topic tags
  3. Technologies: languages, frameworks, tools used
  4. Summary: 2-3 sentences describing what was accomplished

Apply YAML frontmatter to each file:

---
title: "Session title"
date: 2026-01-27
type: feature
outcome: completed
topics:
  - authentication
  - caching
technologies:
  - go
  - redis
---

Step 4: Mark Enriched

After writing frontmatter to each file, update the state file:

ctx system mark-journal <filename> enriched

Step 5: Report

After processing, report:

Confirmation Mode

Interactive (default when user is present): show a summary

of proposed enrichments before applying. Group by type/outcome

so the user can scan quickly rather than reviewing one by one.

Unattended (when running in a loop or explicitly told

"just do it"): apply enrichments directly and report results.

Large Backlogs (20+ entries)

For large backlogs, use the heuristic enrichment script bundled

in references/enrich-heuristic.py. This script infers type,

outcome, topics, and technologies from the title and filename

patterns, then inserts frontmatter and marks state automatically.

How to use

  1. Build a file list of eligible entries (non-multipart, 20+ lines,

missing type: and outcome: fields):

```bash

CTX_PATH=$(ctx system bootstrap -q)

for f in "$CTX_PATH"/journal/*.md; do

[ -f "$f" ] || continue

has_type=$(head -30 "$f" | grep -c '^type:' || true)

has_outcome=$(head -30 "$f" | grep -c '^outcome:' || true)

if [ "$has_type" -eq 0 ] || [ "$has_outcome" -eq 0 ]; then

name=$(basename "$f")

case "$name" in -p[0-9].md|-p[0-9][0-9].md) continue ;; esac

lines=$(wc -l < "$f")

[ "$lines" -ge 20 ] && echo "$f"

fi

done > /tmp/enrich-list.txt

```

  1. Run the heuristic enrichment script. The script path is relative

to this skill's directory: copy it to /tmp or reference it via

the full embedded path:

```bash

python3 references/enrich-heuristic.py /tmp/enrich-list.txt

```

  1. The script handles everything: reads files, inserts frontmatter,

runs ctx system mark-journal for each, and reports counts.

When to use heuristic vs. per-file enrichment

| Backlog size | Approach |

|--------------|---------------------------------------------------|

| 1-5 entries | Read each file, enrich manually with full context |

| 6-20 entries | Sequential processing in the main conversation |

| 20+ entries | Use enrich-heuristic.py for bulk processing |

The heuristic script produces good-enough enrichment from titles

and filenames. For higher quality, follow up with manual review

of entries where the type or topics look wrong.

Subagent parallelization is an alternative for 20+ entries, but

requires that subagents have Edit and Bash permissions granted.

If permissions are restricted, the heuristic script is faster

and more reliable.

Quality Checklist

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.