| name | link |
| description | This skill should be used when the user asks to "link this folder/project to a memory project", "map this directory to project X", "pin this repo to existing memory", accepts a KEY_MISMATCH repair, or invokes /tm:link [id|path]. Forces the current directory to map to an existing turing-mem project folder by writing project_overrides in config.json — cross-host linking for no-remote projects. The mapping is always confirmed before writing. |
| argument-hint | [project-id | store-relative path] |
tm — link
Write a cwd → project mapping into project_overrides in ${XDG_CONFIG_HOME:-$HOME/.config}/turing-mem/config.json. The guard resolves overrides first (longest matching ancestor wins), so the mapped directory and everything under it route to the chosen project folder. Use when:
- a no-remote project was created on another host (host-scoped ids differ per machine) and this clone must reuse the existing synced folder;
- the guard prints
KEY_MISMATCH=true — the derived key differs from the key recorded in the derived project folder's INDEX.md frontmatter (repair flow: the KEY_MISMATCH section of bootstrap.md);
- the user simply wants a directory pinned to a specific project folder.
Auto-trigger only on a clear user ask to link/map/pin this directory (or an accepted KEY_MISMATCH repair) — never from inference; the mapping is always confirmed via AskUserQuestion before anything is written.
1. Guard (always first)
Run ${CLAUDE_PLUGIN_ROOT}/scripts/tm-guard.sh "$PWD" and parse its KEY=VALUE output. If TM_STATUS is not OK, stop and follow the repair flows in <MEMORY_DIR>/references/bootstrap.md (if the store does not exist yet, the same file ships in the plugin at ${CLAUDE_PLUGIN_ROOT}/references/bootstrap.md) — in practice, run /tm:init first; link needs a resolvable store. PROJECT_EXISTS=false does not block link — that is exactly the situation link repairs.
2. Resolve the target project
- Interpret the argument:
- bare project id (e.g.
turing-mem-3f9a12cd) → target projects/<id>;
- store-relative path (e.g.
projects/turing-mem-3f9a12cd) → use as-is;
- no argument → suggest before asking: list
ls <MEMORY_DIR>/projects/, rank the folders by similarity to this session directory (shared name tokens with the dir basename; recorded key: frontmatter overlapping the derived key from ${CLAUDE_PLUGIN_ROOT}/scripts/tm-project-id.sh "$PWD"; ## Projects summaries in the global index), and offer the best 2–3 as named AskUserQuestion options — each showing its recorded key so it is recognizable — with the full list available via the custom/"Other" choice.
- Verify
<MEMORY_DIR>/<target>/INDEX.md exists. If it does not, stop and report — offer /tm:init to create a fresh project folder instead; link never scaffolds.
- The local side of the mapping is the absolute session working directory (
"$PWD") — projects are recognized by session dir, not git root, so a subfolder of a larger repo maps independently. Ancestor matching still covers everything beneath the mapped directory. (Map a broader parent only if the user explicitly asks for the whole repo to share one project.)
3. Confirm and write
- Show the mapping
<abs-local-path> → <target> and the config path; confirm via AskUserQuestion (proceed / adjust / cancel) before writing.
- Update the config with a python3 read-modify-write that preserves all other keys:
CONFIG="${XDG_CONFIG_HOME:-$HOME/.config}/turing-mem/config.json"
python3 - "$CONFIG" "<abs-local-path>" "<target>" <<'PY'
import json, sys
path, local, target = sys.argv[1:4]
with open(path) as f:
cfg = json.load(f)
cfg.setdefault("project_overrides", {})[local] = target
with open(path, "w") as f:
json.dump(cfg, f, indent=2)
f.write("\n")
PY
- Re-run the guard and verify:
TM_STATUS=OK, OVERRIDE=true, PROJECT_PATH=<target>, PROJECT_EXISTS=true. Report the resulting mapping to the user.
Notes
- Key-mismatch repair routes this directory to the chosen folder; it never rewrites the target's
key frontmatter (identity fields are never rewritten).
config.json is machine-local and never synced — repeat /tm:link on each additional machine for no-remote projects.
- Codex note: linking is a Claude-Code-only flow (bootstrap.md says the same). On Codex, hand-edit
config.json as shown above instead of running this skill.