Skip to content

contox hygiene

Run the Memory Hygiene Agent to analyze and clean up memory items. This command uses a two-phase workflow: first analyze to get a plan, then selectively apply the proposed changes.

Usage

bash
contox hygiene [options]

Options

FlagDescriptionRequiredDefault
--mode <mode>Analysis modeNoquick
--schema-key <prefix>Filter items by schema key prefixNo--
--jsonOutput in JSON formatNofalse
--apply <file>Apply actions from a previously saved plan fileNo--
--action-ids <ids>Comma-separated list of action IDs to applyNo--
--dry-runShow what would be applied without executingNofalse

Modes

ModeDescription
quickAnalyze the 20 most recent items (fast, low cost)
weeklyAnalyze all items updated in the last 7 days

Two-phase workflow

The hygiene command is designed to be safe and transparent. Changes are never auto-applied.

Phase 1: Analyze

Run the hygiene agent to get a plan of proposed actions:

bash
contox hygiene

This outputs a list of proposed actions, each with:

  • A unique action ID
  • Description of what the action would do
  • Confidence score (0 to 1)
  • Whether human approval is required

Phase 2: Apply

Review the proposed actions and apply the ones you approve:

bash
contox hygiene --apply plan.json --action-ids "action1,action2,action3"

Examples

Quick analysis of recent items:

bash
contox hygiene

Weekly analysis of all recent changes:

bash
contox hygiene --mode weekly

Analyze only bug-related items:

bash
contox hygiene --schema-key root/bugs

Preview what would be applied:

bash
contox hygiene --apply plan.json --action-ids "act_1,act_2" --dry-run

Get JSON output for scripting:

bash
contox hygiene --json

What it proposes

The hygiene agent can propose the following types of actions:

Action typeDescription
RenameFix unclear or inconsistent titles
RetagUpdate tags for better categorization
MergeCombine duplicate or overlapping items
DeprecateMark superseded or stale items as deprecated
FlagHighlight quality issues for manual review
RedactRemove accidentally stored secrets or sensitive data

Notes

  • The hygiene agent never auto-applies changes. You always review and choose which actions to execute.
  • Each proposed action includes a confidence score. Higher confidence means the agent is more certain the action is correct.
  • Actions with requiresHumanApproval: true should be carefully reviewed before applying, as they involve potentially significant changes.
  • Run hygiene regularly (weekly is recommended) to keep your project brain clean and well-organized.
  • The --dry-run flag on the apply phase shows what would happen without making any changes, giving you an extra safety layer.