|
| 1 | +--- |
| 2 | +# / ctx: https://ctx.ist |
| 3 | +# ,'`./ do you remember? |
| 4 | +# `.,'\ |
| 5 | +# \ Copyright 2026-present Context contributors. |
| 6 | +# SPDX-License-Identifier: Apache-2.0 |
| 7 | + |
| 8 | +title: Connect |
| 9 | +icon: lucide/link |
| 10 | +--- |
| 11 | + |
| 12 | +## `ctx connect` |
| 13 | + |
| 14 | +Connect to a shared context hub for cross-project knowledge sharing. |
| 15 | +Projects publish decisions, learnings, and conventions to a centralized |
| 16 | +hub; other projects receive them alongside local context. |
| 17 | + |
| 18 | +### `ctx connect register` |
| 19 | + |
| 20 | +One-time registration with a shared hub. Requires the hub address and |
| 21 | +admin token (printed by `ctx serve --shared` on first run). |
| 22 | + |
| 23 | +```bash |
| 24 | +ctx connect register localhost:9900 --token ctx_adm_7f3a... |
| 25 | +``` |
| 26 | + |
| 27 | +On success, stores an encrypted connection config in |
| 28 | +`.context/.connect.enc` for future RPCs. |
| 29 | + |
| 30 | +### `ctx connect subscribe` |
| 31 | + |
| 32 | +Set which entry types to receive from the hub. Only matching types |
| 33 | +are returned by sync and listen. |
| 34 | + |
| 35 | +```bash |
| 36 | +ctx connect subscribe decision learning |
| 37 | +ctx connect subscribe decision learning convention |
| 38 | +``` |
| 39 | + |
| 40 | +### `ctx connect sync` |
| 41 | + |
| 42 | +Pull matching entries from the hub and write them to |
| 43 | +`.context/shared/` as markdown files with origin tags and date |
| 44 | +headers. Tracks last-seen sequence for incremental sync. |
| 45 | + |
| 46 | +```bash |
| 47 | +ctx connect sync |
| 48 | +``` |
| 49 | + |
| 50 | +### `ctx connect publish` |
| 51 | + |
| 52 | +Push entries to the hub. Specify type and content as arguments. |
| 53 | + |
| 54 | +```bash |
| 55 | +ctx connect publish decision "Use UTC timestamps everywhere" |
| 56 | +``` |
| 57 | + |
| 58 | +### `ctx connect listen` |
| 59 | + |
| 60 | +Stream new entries from the hub in real-time. Writes to |
| 61 | +`.context/shared/` as entries arrive. Press Ctrl-C to stop. |
| 62 | + |
| 63 | +```bash |
| 64 | +ctx connect listen |
| 65 | +``` |
| 66 | + |
| 67 | +### `ctx connect status` |
| 68 | + |
| 69 | +Show hub connection state and entry statistics. |
| 70 | + |
| 71 | +```bash |
| 72 | +ctx connect status |
| 73 | +``` |
| 74 | + |
| 75 | +## Shared files |
| 76 | + |
| 77 | +Entries from the hub are stored in `.context/shared/`: |
| 78 | + |
| 79 | +``` |
| 80 | +.context/shared/ |
| 81 | + decisions.md # Shared decisions with origin tags |
| 82 | + learnings.md # Shared learnings |
| 83 | + conventions.md # Shared conventions |
| 84 | + .sync-state.json # Last-seen sequence tracker |
| 85 | +``` |
| 86 | + |
| 87 | +These files are read-only (managed by sync/listen) and never |
| 88 | +mixed with local context files. |
| 89 | + |
| 90 | +## Agent integration |
| 91 | + |
| 92 | +Include shared knowledge in agent context packets: |
| 93 | + |
| 94 | +```bash |
| 95 | +ctx agent --include-shared |
| 96 | +``` |
| 97 | + |
| 98 | +Shared entries are included as Tier 8 in the budget-aware |
| 99 | +assembly, scored by recency and type relevance. |
0 commit comments