Universal agent skill for Context Crystal. Automates context lifecycle management, state transitions, session persistence, context cleavage, and prompt hydration with zero learning curve for users.
This skill equips AI coding entities (Antigravity, Claude Code, Cursor, Windsurf, Jetski) to manage, persist, and advance long-running computational contexts using the Context Crystal engine (ccrystal).
--fidelity inferred.crystal_batch, crystal_search, crystal_hydrate, crystal_triage, crystal_init, crystal_checkpoint, crystal_task_transition, crystal_goal_transition, crystal_transient_lease, crystal_slice_fork, crystal_melt, crystal_connect, crystal_archive, crystal_unarchive, crystal_prune, crystal_artifact) and resources (ccrystal://artifacts, ccrystal://{id}/artifacts, ccrystal://{id}/bonds) over shell subprocesses. For multi-step transitions, compose a single crystal_batch recipe or ccrystal batch command to execute atomically with minimal turn roundtrips.CCRYSTAL_STORE). Respect user repository policies to prevent polluting production code with local tracking files..ccrystals/ DAG nodes, envelopes, or artifacts. When recording tool execution outputs or logs, redact sensitive authorization headers (e.g. Bearer <REDACTED>) and tokens. Crystals may contain pointer references (env:VAR_NAME, vault URIs) and discuss secret handling, but must remain strictly zero-secret artifacts. Entities must NEVER run commands that dump, echo, print, or grep environment variables (env, printenv, export), process lists, or credential store files that risk leaking sensitive tokens into tool outputs or transcripts. When CLI tools report authentication failures, pause and request the human operator's assistance rather than attempting environmental secret harvesting.ccrystal list, ccrystal search, or MCP crystal_search). If an existing crystal relates to the session context or feature track, attach to it and hydrate context (ccrystal hydrate or MCP crystal_hydrate) before making code edits. If none exists, initialize a new crystal with atomic acceptance criteria (crystal_init with tasks or ccrystal init -t ...). Never proceed through multi-turn refactors or feature tracks without active crystal anchoring.ccrystal list, ccrystal search, or MCP crystal_search). If an active crystal is in-flight, hydrate its living context beam (ccrystal hydrate <id> or MCP crystal_hydrate) to restore active tasks, transient resource leases, and causal state into working memory.ccrystal slice <id> --fork-to <child-id> or MCP crystal_slice_fork).ccrystal conclude or MCP crystal_goal_transition), resolve all transient leases, and initialize a new dedicated crystal (crystal_init or ccrystal init).--help & --for-ai): Because ccrystal's CLI parser is statically generated via Decline ADTs, running ccrystal --help and ccrystal <subcommand> --help is the guaranteed source of truth for all available subcommands, flags, defaults, and syntax. When choosing between MCP and CLI, or when discovering newly implemented capabilities that might not yet be exposed in a specific agent's MCP schema, the entity should run ccrystal --help or ccrystal <subcommand> --help to verify current options. Additionally, ccrystal --for-ai emits agent-specific operational rules, naming conventions, and PII invariants on demand.ccrystal lesson add <id> -o "Attempted X: failed because Y" -r "<root cause>" -a "Avoid X; use Z instead" (or via MCP crystal_batch). Because ContextHydrator deterministically injects all Open lessons into every context beam under ## Unresolved Lessons Learned:, the agent (and future resuming entities) avoids repeating failed attempts with 0 LLM tokens spent on re-summarization or memory retrieval. Once codified into permanent repository rules (AGENTS.md), transition the lesson to actioned (ccrystal lesson actioned <id>).crystal_archive or ccrystal archive, explicitly reason: Did this session spawn external dependencies or temporary workspace resources that would cause amnesia or orphaned artifacts if hidden? If so, the goal is not yet finished. Keep the crystal in active status, register explicit monitoring tasks (task-N), and register transient resource leases (crystal_transient_lease / ccrystal transient lease) to defend in-progress workspace resources against premature teardown.ccrystal connect or slice-forking). Resuming entities hydrate the crystal directly, consuming hundreds of tokens of high-density truth rather than tens of thousands of tokens of lossy conversation.ccrystal slice --fork-to) so the core goal can conclude while exploration flourishes.concluded_success.crystal_checkpoint) or transition completed tasks (crystal_task_transition). Never leave verified milestones stranded only in the ephemeral chat window.crystal_transient_lease clean) or defend active leases with in-flight tasks. Never leave unmanaged mock configurations or dangling temporary files behind.Open lessons (ccrystal lesson add or MCP crystal_batch) before the chat transcript is closed.crystal_triage / ccrystal triage to classify active crystals. Recommend moving concluded crystals to cold storage (crystal_archive) to keep the active cave minimal and focused for the next session.Before invoking any ccrystal commands, verify that the binary is available in the execution environment:
which ccrystal || command -v ccrystal || [ -f "$HOME/.local/bin/ccrystal" ]
If ccrystal is not present in PATH:
Ensure ~/.local/bin exists and is in PATH:
mkdir -p "$HOME/.local/bin"
export PATH="$HOME/.local/bin:$PATH"
Fetch the native release binary or install from source:
Automated Installer (Recommended):
curl -fsSL https://raw.githubusercontent.com/oswaldo/context-crystal/main/install.sh | sh
Universal JVM & Windows Bootstrap (Zero-Install via Coursier): If running on Windows, an architecture without native binaries, or an environment with Java/Coursier available:
# Launch on-demand without installation
cs launch io.github.oswaldo:ccrystal-cli_3:latest.release -- <command>
# Or install globally into user PATH
cs install io.github.oswaldo:ccrystal-cli_3:latest.release --name ccrystal
Monorepo Fallback (When in Context Crystal repository):
sbt "cliNative/nativeLink" && cp ./cli/native/target/scala-3.9.0/ccrystal-cli "$HOME/.local/bin/ccrystal" && chmod +x "$HOME/.local/bin/ccrystal"
Test availability and discover ground-truth capabilities:
ccrystal --help
--help & --for-ai)ccrystal --help and ccrystal <subcommand> --help as the live, authoritative contract for command-line syntax and flags. Because Decline compiles CLI parsers directly from source ADTs, --help never drifts from binary reality.ccrystal --help or ccrystal <subcommand> --help as the definitive source of truth.ccrystal --for-ai.kebab-case, PascalCase, or snake_case forms interchangeably:--kind, -k): human_prompt, agent_reasoning, tool_execution, checkpoint, branch, resolution--type, -t): git_worktree, env_override, debug_config, dummy_asset, mock_service--policy): revert_on_conclusion, delete_after_test, replace_in_final_cut, manual--kind, -k): human, agent, model, system, tool--fidelity): inferred, intercepted--status): in_progress, concluded_success, concluded_abandoned--role): target, instrument, precondition--substrate): virtual, physical--state): active, solid, stale--relation, -r): relates_to, depends_on, blocks, supersedes, referencesccrystal agent)Context Crystal operates on the Golden Triad model:
ccrystal): The engine and deterministic CLI.ccrystal mcp): Real-time interactive tool calls and prompt resources.SKILL.md): Autonomous cognitive reflexes, task ceremonies, and anti-amnesia re-anchoring protocols.Agents can autonomously diagnose Golden Triad readiness and deploy both MCP configurations and skills across detected harnesses:
# Non-destructive environment, MCP configuration, and agent skill diagnostics
ccrystal agent doctor
# Auto-configure Context Crystal and deploy skills across all detected harnesses (with .ccrystal.bak backups)
ccrystal agent install
# Deploy skill as a symlink pointing to workspace canonical skill for live development
ccrystal agent install --symlink-skill
# Install canonical skill into local repository workspace (.agents/skills/context-crystal/SKILL.md)
ccrystal agent install --workspace-skill
# Preview configuration and skill distribution without disk changes
ccrystal agent install --dry-run
Context Crystal decouples the Code Workspace from the Context Store. When determining where to persist crystals, evaluate in this order:
Explicit CLI / Environment Override:
CCRYSTAL_STORE is set in the environment or passed via --store <path>, use that directory.Workspace Pointer File:
.ccrystal-store exists in the workspace root. If present, read its path pointer.Clean Repository Preference:
If the workspace is a strict/public repository (or the user requests a clean working tree without .ccrystals/), set CCRYSTAL_STORE to an external companion directory, e.g.:
export CCRYSTAL_STORE="$HOME/.ccrystals/stores/$(basename "$PWD")"
Default In-Tree Storage:
.ccrystals/ directory.The skill automatically adapts its update cadence and token usage based on the host project's workflow infrastructure:
βββββββββββββββββββββββββββββ
β Project Environment Check β
βββββββββββββββ¬ββββββββββββββ
β
ββββββββββββββββββββββββ΄βββββββββββββββββββββββ
βΌ βΌ
[Process Framework Found] [No Process Tool Found]
(conductor/, openspec/, speckit/, adr/) (Freeform conversational flow)
β β
βΌ βΌ
Symbiotic Mode Autonomous Spine Mode
(Low Token Overhead) (Compaction & Crash Proof)
β’ Sync only at phase boundaries β’ Manages tasks directly in tasks.md
β’ Ingest at session start β’ Flushes batch delta before yielding turn
β’ Cleave on out-of-scope branch β’ Checkpoints on logical milestones
Active when conductor/, .conductor/, openspec/, speckit/, or docs/adr/ is present.
ccrystal after every single tool call or minor edit. Allow the host framework to drive minute tasks.Session Inception & Hydration: Cast existing crystal or initialize aligned with the track goal:
ccrystal hydrate <crystal-id>
# Or selectively shape the context beam to conserve tokens:
ccrystal hydrate <crystal-id> --tail 10
ccrystal hydrate <crystal-id> --from <anchor-or-node-prefix>
# Or initialize if first session:
ccrystal init <crystal-id> -g "<Goal Title>" -i "<Detailed Intent>" --created-at "<ISO-8601>"
Phase / Milestone Boundaries: When tests pass or a plan phase completes, record an atomic batch transition:
ccrystal batch "node add <crystal-id> -k checkpoint -s 'Phase complete: <summary>' --fidelity inferred; task done <crystal-id> -t <task-id>"
Historical Event Batching: When syncing multiple completed actions from git logs or OpenSpec tasks, supply explicit --timestamp <ISO-8601> flags to preserve true chronological fidelity rather than collapsing into a single second:
ccrystal batch "node add <id> -k tool_execution -s 'Ran migration' --timestamp 2026-09-06T14:10:00Z; node add <id> -k checkpoint -s 'Tests green' --timestamp 2026-09-06T14:25:00Z"
Cleavage / Divergence: When an adjacent bug or exploration emerges that diverges from the main track, cleave and fork cleanly:
ccrystal slice <crystal-id> --from <anchor> --fork-to <child-crystal-id> --prune
Hand-Off & Conclusion: Clean temporary leases and log actionable friction:
ccrystal batch "transient clean <crystal-id> -l <lease-id>; lesson add <crystal-id> -f '<Observed friction>' -r '<Root cause>' -a '<Remediation>'"
Artifact & World-State Linkage: Register long-lived tools, virtual mocks, or physical lab environments in the Cave Registry or crystal scope, and link them directionally:
ccrystal artifact register --id dev-rig-1 --name 'Development Rig' --substrate physical --role instrument --cave
ccrystal node add <crystal-id> -k tool_execution -s 'Execute firmware test' --input-artifact dev-rig-1 --output-artifact test-report-1
Active when no external planning tool is present.
tasks.md), lessons learned (lessons-learned.md), and temporary resources (transient.json).spec.md or plan.md, the crystal's DAG nodes and lessons must be semantically dense to prevent future sessions from reinvestigating settled topics."Fixed connection timeout""Resolved pool starvation in db/pool.go by configuring max idle conns to 20 and keep-alives; discarded connection pooling wrapper because it introduced deadlocks on rollbacks"lesson add <id> -f '<friction>' -r '<root cause>' -a '<remediation>'ccrystal hydrate, it immediately inherits the settled rationale and never wastes tokens re-exploring discarded paths.ccrystal hydrate <crystal-id> reconstitutes the exact state without data loss.When the user communicates in natural language, translate their intent into the following atomic CLI commands:
| User Utterance / Intent | Meaning | Recommended CLI Recipe |
|---|---|---|
| "Crystallize this session", "Save checkpoint" | Snapshot current state and progress | ccrystal batch "node add <id> -k checkpoint -s '<summary>' --fidelity inferred" |
| "Resume last task", "What are we working on?", "Cast context" | Hydrate prompt with goals, active tasks, recent nodes, open leases | ccrystal hydrate <id> (or MCP crystal_hydrate) |
| "Hydrate from checkpoint X", "Show context since anchor" | Selectively hydrate prompt from an anchor, UUID, or prefix forward | ccrystal hydrate <id> --from <selector> (or MCP crystal_hydrate) |
| "Cast range between X and Y", "Shape context beam" | Shape context beam between two specific nodes or anchors | ccrystal cast <id> --from <selA> --to <selB> (or MCP crystal_hydrate) |
| "Show recent 5 nodes of context", "Hydrate tail" | Hydrate living state and only the most recent N DAG transitions | ccrystal hydrate <id> --tail 5 (or MCP crystal_hydrate) |
| "Hydrate high-level context only", "Cast summary" | Hydrate goal, tasks, leases, and lessons without DAG transitions | ccrystal hydrate <id> --summary-only (or MCP crystal_hydrate) |
| "We hit a blocker / build error", "Log a lesson" | Record friction and corrective action | ccrystal lesson add <id> -f '<friction>' -r '<cause>' -a '<action>' |
| "Set up a temporary branch / mock config" | Acquire a transient resource lease | ccrystal transient lease <id> -t git_worktree -p '<path>' -d '<desc>' --policy revert_on_conclusion |
| "We're done with the spike, clean it" | Release/clean transient resource | ccrystal transient clean <id> -l <lease-id> |
| "This bug is unrelated, let's track it separately" | Cleave context and fork into child crystal | ccrystal slice <id> --from <anchor-or-node> --fork-to <child-id> --prune |
| "Find crystals about X", "Search crystals from yesterday", "What crystals are in progress?" | Search and inspect crystals with multi-dimensional filters or status queries | ccrystal search [-q '<query>'] [--since <time>] [--until <time>] [--status <status>] [--limit <N>] (or MCP crystal_search) |
| "Cave statistics", "How much disk is the cave using?", "Token savings stats" | Compute quantitative metrics, physical disk footprints, and token savings | ccrystal stats [--since <time>] [--status <status>] [--detailed] [--json] (or MCP crystal_stats) |
| "Triage workspace cave", "What crystals can we clean?" | Classify cave crystals for lifecycle hygiene | crystal_triage |
| "Complete task X" | Mark acceptance criterion done | ccrystal task done <id> -t <task-id> |
| "Conclude crystal X", "We're finished with this project" | Conclude crystal goal and record resolution node | ccrystal conclude <id> [-s '<summary>'] (or MCP crystal_goal_transition) |
| "Abandon crystal X", "This approach didn't pan out" | Abandon crystal goal and record resolution node | ccrystal abandon <id> [-r '<reason>'] (or MCP crystal_goal_transition) |
| "Register artifact / tool X", "Add physical device / hardware rig" | Register virtual or physical artifact in cave or crystal | ccrystal artifact register --id <id> --name '<name>' --substrate <virtual|physical> --role <target|instrument|precondition> [--uri <uri>] [--location-name '<loc>'] [--bench-coords '<coords>'] |
| "What artifacts are available?", "List tools / hardware" | List artifacts across cave or within a crystal | ccrystal artifact list [--cave] [--crystal <id>] |
| "Inspect artifact X", "Check test rig location / details" | Inspect metadata, substrate, and physical location of artifact | ccrystal artifact inspect <id> [--crystal <id>] |
| "Execute test using rig X", "Link artifact inputs / outputs" | Record transition with directional artifact links | ccrystal node add <id> -k tool_execution -s '<summary>' --input-artifact <in-id> --output-artifact <out-id> --precondition-artifact <pre-id> |
| "Melt intermediate steps in crystal X", "Squash nodes from N1 to N2" | Deterministically squash sub-DAG path into single checkpoint | ccrystal melt <id> --from <from> --to <to> [--summary '<text>'] (or MCP crystal_melt) |
| "Connect crystal A to B", "Link dependencies between crystals" | Connect two crystals with directed semantic relation | ccrystal connect <source> <target> -r <rel> [-d '<desc>'] (or MCP crystal_connect) |
| "Disconnect crystal A from B", "Sever cross-crystal link" | Sever directed lattice bond between crystals | ccrystal disconnect <source> <target> [-r <rel>] (or MCP crystal_connect) |
| "Show crystal connections", "What crystals depend on X?" | Inspect outbound and inbound cross-crystal bonds | ccrystal connections <id> [--json] (or MCP crystal_connect) |
| "Archive crystal X", "Move completed crystal to cold storage" | Move concluded/inactive crystal to cold storage (.ccrystals/archive/) |
ccrystal archive <id> (or MCP crystal_archive) |
| "Restore crystal X from archive" | Restore archived crystal back to active cave | ccrystal unarchive <id> (or MCP crystal_unarchive) |
| "Triage solid / stale crystals", "Filter cave hygiene" | Triage crystals with aging filters (--solid, --stale, --active) |
ccrystal triage [--solid|--stale] (or MCP crystal_triage) |
| "Prune crystal X", "Remove scratch session", "Prune cold storage" | Permanently prune crystal or batch prune cold storage archives by age | ccrystal prune [<id>] [--older-than <duration>] [--all] [-f] (or MCP crystal_prune) |
| "Deregister entity X", "Remove actor from cave" | Deregister entity and cascade-delete associated crystals | ccrystal entity deregister <entity-id> (or -f when automated) |
ccrystal batch)The batch subcommand executes multiple statements in a single sub-millisecond process execution. Commands are separated by semicolons (;).
ccrystal batch "init my-feature -g 'OAuth2 Authentication' -i 'Implement PKCE flow'; task add my-feature -d 'Design schema'; task add my-feature -d 'Implement token exchange'; task add my-feature -d 'Verify test suite'"
ccrystal batch "node add my-feature -k checkpoint -s 'Schema finalized' --fidelity inferred; task done my-feature -t task-1; transient lease my-feature -t debug_config -d 'OAuth test sandbox credentials' --policy revert_on_conclusion"
ccrystal batch "task done my-feature -t task-3; conclude my-feature -s 'OAuth2 flow verified with 100% test coverage'; transient clean my-feature -l lease-1; lesson add my-feature -f 'PKCE code challenge salt collision' -r 'Used weak PRNG in mock' -a 'Always use java.security.SecureRandom'"
ccrystal batch "delete scratch-spike -f; init scratch-spike -g 'Spike 2' -i 'Fresh exploration'"
ccrystal batch "artifact register --id rig-sensor-1 --name 'Oscilloscope Station' --substrate physical --role precondition --location-name 'Hardware Lab' --bench-coords 'Bench-4' --cave; node add my-feature -k tool_execution -s 'Executed signal sampling' --precondition-artifact rig-sensor-1 --output-artifact waveform-dump-1"
ccrystal batch "melt my-feature --from init-node --to milestone-1 -s 'Scaffolding & DB schema finalized'; archive completed-spike"
ccrystal batch "connect track-auth-core track-api-gateway -r depends_on -d 'Gateway relies on token verification contract'; connections track-auth-core"
Zero Unprompted PII Persistence: An AI entity MUST NEVER record Personally Identifiable Information (personal names, private email addresses, phone numbers, physical addresses, personal API keys/tokens, private corporate IDs, or customer data) into a crystal (init, node add, task add, lesson add, transient lease) without proactively consulting the operator.
Context Space Awareness (Public vs. Private): Crystals (.ccrystals/) are designed to be committed to version control, published to remote stores, or shared across multi-agent pipelines. If the repository or destination store is public or shared:
usr_lead_developer, [REDACTED_EMAIL]).Canonical Entity Conventions & ID Schemes:
All Cave entities follow <prefix>_<slug>:
| Prefix | Kind | Example Handle | Canonical Entity ID | Description |
|---|---|---|---|---|
usr_ |
Human | john / lead |
usr_john / usr_lead |
First name or role alias. Display name defaults to handle. Avoid full legal names or accents. |
agt_ |
Agent | antigravity |
agt_antigravity |
Autonomous pairing agent or entity. |
mdl_ |
Model | gemini-flash |
mdl_gemini_flash |
Model backend or LLM architecture. |
tool_ |
Tool | bash-runner |
tool_bash_runner |
External tool, compiler, or runner. |
sys_ |
System | git-sync |
sys_git_sync |
Background subsystem or daemon. |
Operator Preference & Persistent Memory Invariant:
AGENTS.md, or rules) for the operator's preferred entity handle and privacy stance before prompting.git config user.name or OS environment variables without explicit operator confirmation.Idempotent Handle Resolution: CLI options (--author) and MCP parameters (author) accept the bare handle (antigravity, oswaldo). Even if an agent accidentally supplies an already-prefixed handle (agt_antigravity, usr_oswaldo), ccrystal's store defensively strips redundant prefixes, guaranteeing idempotent canonical IDs (agt_antigravity, usr_oswaldo) without duplicate prefix nesting (agt_agt_...).
CLI Guidance Invariants:
ccrystal --for-ai to retrieve dense operational invariants directly from the CLI binary.ccrystal entity conventions to display the canonical prefix reference table.Strict Rule: The AI entity MUST ALWAYS ask and NEVER assume when PII is involved.
Over weeks or months of continuous delivery, crystals accumulate in the workspace cave (.ccrystals/). As projects evolve, completed features, concluded tracks, or abandoned experiments consume space and clutter context listings.
AI entities support operators in maintaining optimal cave hygiene through deterministic aging classification and cold storage archiving:
crystal_triage MCP tool or ccrystal triage.ccrystal list or MCP crystal_list reports multiple completed or stale goals ready for housekeeping.Context Crystal deterministically classifies crystals into three aging states:
concluded_success or concluded_abandoned.100%).0.0 (or lessons already incorporated into codebase documentation/ADRs).0 (no pending upstream PRs, unverified registry submissions, or challenge emails).ccrystal archive <id> (or MCP crystal_archive). This removes the crystal from the active cave while preserving 100% of state, history, and artifacts under .ccrystals/archive/<id>/.in_progress with no activity for >30 days, or abandoned with unresolved transient leases or incomplete acceptance criteria.ccrystal archive or MCP crystal_archive, explicitly reason whether the session spawned in-flight asynchronous commitments (upstream PRs, registry submissions, verification emails) or unregistered workspace resources (temporary git worktrees, clones, mock services). If external commitments remain in-flight, do NOT archive prematurely: keep the crystal active with explicit monitoring tasks (task-N) and transient resource leases (git_worktree). Only archive when both code milestones and external verification loops are fully resolved.ccrystal archive <id> / MCP crystal_archive) over permanent pruning. Archived crystals can be inspected at any time with ccrystal list --archived and restored seamlessly via ccrystal unarchive <id>.ccrystal prune [<id>] / MCP crystal_prune) is irrecoverable and cascades to all associated nodes and leases. The AI entity MUST request explicit confirmation from the operator before executing un-previewed pruning operations, never pruning unprompted without --dry-run or explicit operator instruction.