# Init Context

> Initialize a context-harness personal context home, data directories, global context files, and optional Codex/Claude Code hooks. Use when the user asks to initialize context-harness, set up a personal context system, configure automatic Code Agent conversation backup, or repair context-harness hooks.

- **Type:** Skill
- **Install:** `agentstack add skill-yinjialu-context-harness-init-context`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [yinjialu](https://agentstack.voostack.com/s/yinjialu)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [yinjialu](https://github.com/yinjialu)
- **Source:** https://github.com/yinjialu/context-harness/tree/main/skills/init-context

## Install

```sh
agentstack add skill-yinjialu-context-harness-init-context
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Init Context

Use this skill to initialize or repair a `context-harness` installation. The skill can bootstrap the CLI runtime even when only the skill was installed.

## Runtime Bootstrap

Before running `context-harness`, execute the bundled bootstrap script from this skill directory:

```bash
runtime_dir="$(bash scripts/bootstrap.sh)"
cd "$runtime_dir"
```

The script clones or updates the runtime repository at `~/.local/share/context-harness` by default, checks out the latest released tag, and runs `uv sync`.

Overrides:

- `CONTEXT_HARNESS_RUNTIME_DIR`: custom runtime checkout path.
- `CONTEXT_HARNESS_REPO_URL`: custom fork URL.
- `CONTEXT_HARNESS_REF`: custom branch, tag, or commit.
- `CONTEXT_HARNESS_BOOTSTRAP_SKIP_UPDATE=1`: skip fetch/pull.

## Workflow

1. Run the Runtime Bootstrap steps above. Use the returned path as the `context-harness` repository root.
2. Choose the data home:
   - Use `CONTEXT_HARNESS_HOME` when set.
   - Use the user's explicit path when provided.
   - Otherwise use `~/.context-harness`.
3. Run all `uv run context-harness ...` commands from the runtime repository root:

```bash
uv run context-harness --context-home  init
```

`init` also binds the data home's `global-claude.md` into agent-level context:

- Claude Code: adds an `@import` line to `~/.claude/CLAUDE.md` (creating that file if absent).
- Codex: adds a managed Context Harness block to `~/.codex/AGENTS.md` (creating that file if absent) that tells Codex to read the same global context file at the start of new sessions.

This is idempotent and non-destructive — existing CLAUDE.md and AGENTS.md content is preserved, and re-running reports `CLAUDE.md: unchanged` and `AGENTS.md: unchanged`. After a fresh link, the user must restart Claude Code or start a new Codex session for the context to load.

4. If the user wants automatic backup hooks, run these commands from the same repository root. Supported Code Agents install to user-level config by default. Use `--scope project` to install into the current project, or combine it with `--project-root` to target another project:

```bash
uv run context-harness --context-home  hooks install codex
uv run context-harness --context-home  hooks install codex --scope project
uv run context-harness --context-home  hooks install codex --scope project --project-root 
uv run context-harness --context-home  hooks install claude-code
uv run context-harness --context-home  hooks install claude-code --scope project
uv run context-harness --context-home  hooks install claude-code --scope project --project-root 
```

5. Report the data home and hook status.

Do not store user conversations or memory inside the `context-harness` repository unless the user explicitly chooses that path as the data home.

## OKF Layout

`init` scaffolds an Open Knowledge Format knowledge base: it writes a root `index.md` and OKF-shaped templates for `memory/MEMORY.md` (`type: Index`), `memory/user_profile.md` (`type: user`) and `global-claude.md` (`type: Personal Context`). It is idempotent — re-running reports `index.md: unchanged`.

If the user points `init` at a data home that already holds pre-OKF archives (no frontmatter), upgrade it once with the idempotent migration:

```bash
uv run context-harness --context-home  migrate-okf --dry-run   # preview
uv run context-harness --context-home  migrate-okf             # apply
```

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [yinjialu](https://github.com/yinjialu)
- **Source:** [yinjialu/context-harness](https://github.com/yinjialu/context-harness)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-yinjialu-context-harness-init-context
- Seller: https://agentstack.voostack.com/s/yinjialu
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
