ctx user guide

Getting started

Install ctx

Prepare your shell for a client workspace, then check that ctx can find the tools it needs.

Install on your machine

Run the full installer in a macOS or Linux terminal. On Windows, open a WSL2 Linux shell first. The installer sets up the CLI and shell integration. For a reproducible installation, use a release tag you have reviewed in place of main.

curl -fsSL https://raw.githubusercontent.com/Hei-Tech-Inc/ctx/main/install.sh | bash

Check your installation

Open a fresh terminal so the shell loads the installed hook. The version command confirms which release is on your path. Doctor checks the shell hook, SSH include and integration tools. A machine with no client profiles can still run these checks.

ctx version
ctx doctor

Getting started

Create a profile

Use one profile per client so Git, GitHub and your cloud tools use the intended identity.

Choose an identity and folder

Start the wizard and choose full setup. For this guide, use acme as the profile name. Supply your client Git name and email, and choose a dedicated work directory such as ~/clients/acme. Select the SSH key and cloud accounts that belong to the client. Review the paths and identities before confirming.

ctx setup

Check the saved profile

The dashboard shows the workspace, Git email, SSH key path and configured integrations together. Verify checks the profile’s paths and GitHub SSH authentication. A warning about a missing key can be expected if you skipped SSH setup.

ctx dashboard
ctx verify acme

Start with Git only

Choose clone-only setup if you just need a GitHub SSH alias today. Extend the same profile later when you know the workspace and cloud settings.

ctx setup --scope clone
ctx setup --extend acme

Daily use

Switch workspaces

Use the current directory to select a profile, or activate one explicitly for a terminal session.

Enter the client folder

Change into the directory you selected during setup. At the next prompt, inspect the active profile. In a client repository, git config user.email should match the email in your dashboard.

cd ~/clients/acme
ctx status
echo "$CTX_ACTIVE_PROFILE"

Switch manually

Use the shell function installed by ctx to apply the profile variables to your current terminal. To see when automatic switching happens, enable transition messages. Clear a manual activation with deactivate.

ctx use acme
ctx config autoswitch-notify on
ctx deactivate

Resolve a nested workspace

When several clients share a repository, place a .ctx file containing profile=acme in the directory that belongs to that client. The nearest override takes precedence. Check the result from inside that directory.

ctx status --json

Daily use

Clone with GitHub

Route a clone through the client’s SSH alias and confirm the repository uses its Git identity.

Clone into the workspace

Replace ORG and REPO with a repository you can access. Start in the client folder. The profile option selects the GitHub SSH alias even if a different profile is active.

cd ~/clients/acme
ctx clone -p acme git@github.com:ORG/REPO.git

Inspect the checkout

Enter the new repository. Its origin should use github-acme for the SSH host. Compare the email with the profile before committing. Verify tests the client SSH connection.

cd REPO
git remote get-url origin
git config user.email
ctx verify acme

Guard commits and pushes

Install the Git guard if you want ctx to check the email on commit and the SSH alias on push. Check its status inside the repository because a repository-specific hooks path can take precedence.

ctx guard install
ctx guard status

Automation

Run commands and scripts

Give one process the client identity without switching every other terminal.

Run with a named profile

Put the program and its arguments after the double dash. The child inherits the profile’s Git identity, GitHub credentials and configured cloud variables. For kubectl, pass the intended context explicitly.

ctx run -p acme -- git var GIT_AUTHOR_IDENT
ctx run -p acme -- gh auth status

Read structured checks

Use list to enumerate profiles and status to inspect activation. Doctor emits machine-wide checks. Verify emits profile checks and returns status 1 on failure. For diagnostic results, inspect each check’s level and message.

ctx --json list
ctx --json status
ctx --json doctor
ctx --json verify acme

Store a secret

Set the value at the interactive prompt to avoid putting it in your command history. List shows key names. Processes launched with ctx run can receive the profile’s stored secrets, so select the child process deliberately.

ctx secret set acme API_TOKEN
ctx secret list acme

Cloud accounts and clusters

Activate a client workspace

Configure cloud accounts during setup, or extend an existing profile. Activating it applies the configured AWS profile, Azure subscription, Google Cloud project and account, and kubectl context. Check the active context before working on a cluster.

ctx setup --extend acme
ctx use acme
kubectl config current-context

Run one cloud command

Use a named profile to run the AWS CLI with that profile’s AWS environment. For a single kubectl process, supply the context explicitly. Replace acme-dev with the context from your own kubeconfig.

ctx run -p acme -- aws sts get-caller-identity
ctx run -p acme -- kubectl --context acme-dev get namespaces

Scripts and repository agent rules

Scope a single process

Run a tool with the profile’s Git author, SSH identity, GitHub credentials and configured cloud variables. Use the folder’s profile by default or pick one by name.

ctx run -p acme -- git var GIT_AUTHOR_IDENT

Give agents repository instructions

Preview the instructions, then use --write in the repository to add the managed section to AGENTS.md. It tells agents how to check identity, scope credentialed commands and respond to a blocked commit.

ctx agent-rules
ctx agent-rules --write

Dashboard and live checks

Compare client profiles

The dashboard shows each client’s workspace, active state, Git identity, SSH key path and configured integrations from saved profile metadata.

ctx dashboard

Verify one profile or diagnose the machine

Use verify for a live SSH and GitHub identity check on one client. Use doctor to inspect installed tools, shell hooks and profile setup across the machine. Both commands support JSON for scripts.

ctx verify acme
ctx doctor --json

Repeatable setup and migration

Preview a repeatable setup

Prepare a KEY=value configuration using examples/setup.noninteractive.conf.example in the project repository. Preview the changes before applying the same configuration without prompts.

ctx setup --config setup.conf --dry-run
ctx setup --config setup.conf -y

Export on the old machine

Export profiles, Git identities and ctx SSH host configuration to a directory. Transfer that directory to the new machine. Restore SSH keys and secret values separately.

ctx config export ~/ctx-migration

Import on the new machine

Import the bundle from its new location, restore the credentials with your configured provider, and check that workspace paths and accounts match this machine.

ctx config import ~/ctx-migration
ctx doctor
ctx verify acme

Agent operations

Kubernetes with MCP

The local ctx MCP server gives an agent tools for one client’s clusters, namespaces, services, and runbooks. It uses ctx-core, the client’s login procedure, and the kubectl installed on the operator’s machine.

Initialize client knowledge

Inside your client workspace, create the knowledge directory. Edit clusters.yaml to describe login, environments.yaml to map names to a cluster and namespace, and services.yaml to map aliases to workloads. Recipes live in recipes/ and operator scripts in scripts/.

ctx knowledge init acme

Register a local agent

Choose the command for your MCP client. Start a new agent session in the client workspace. Folder scope determines the profile; outside a matching folder only client_context is offered. Adding a root that changes the client scope disables the session’s scoped tools and stops its port-forwards.

ctx mcp install claude
# Or, for Cursor:
ctx mcp install cursor

Use a cluster password

Store the value with the interactive secret prompt. List CLUSTER_PASSWORD under the cluster’s login.secrets and reference the variable in the operator-defined login command. For an existing kubeconfig login, specify both its path and context.

ctx secret set acme CLUSTER_PASSWORD

Investigate a service

Start with client_context. Use login, discover_services, logs, trace, describe_service and kubectl_read to investigate the selected environment. search_knowledge and get_recipe retrieve client guidance. activity shows earlier operations. For example, ask your agent to trace a request ID through two named services in staging.

Approve a change

restart, network_test, port_forward, kubectl_change, save_recipe, save_service and save_script ask for confirmation through the MCP host. Review the profile, environment, cluster, namespace and exact action. Protected environments require the canonical environment name. If the host cannot prompt, ctx returns a manual command and skips execution.

Review what was recorded

Inspect activity.jsonl and exports/ under the client knowledge directory. Configured profile and cluster login secret values are redacted in tool output and activity. Kubernetes Secret data and stringData are masked. Treat exported application logs as client data; applications can contain other sensitive content.

Credentials

Passwords and secret stores

A profile records secret key names. The selected provider stores their values. Choose the provider before adding secrets so you know where credentials will be read and written.

Choose a native provider

auto selects the platform default. Keychain uses macOS Keychain. The file provider stores one file per key under ~/.ctx/secrets/<profile>/ with mode 0600; use disk encryption. The pass provider uses the Unix GPG password store at ctx/<profile>/<KEY>. Initialize pass with your own GPG identity before selecting it.

ctx config secret-provider pass
ctx doctor

Set and inspect a key

Enter the password at the prompt. list prints names; get prints the value and is best kept out of logs and recordings. For setup-managed injection, include the intended key name in the profile’s SECRET_KEYS. The cluster login can separately declare required keys in login.secrets.

ctx secret set acme CLUSTER_PASSWORD
ctx secret list acme

Migrate a profile’s values

Migration copies values between native providers on the machine. For example, copy from file storage into an initialized pass store, then select pass and verify the profile’s keys. The copy operation and provider selection are separate steps.

ctx secret migrate acme pass file
ctx config secret-provider pass
ctx secret list acme

Move to another laptop

Export/import carries profile and identity configuration. Restore secret values separately from your chosen provider, provision the required SSH keys, then verify the imported profile.

ctx config export ~/ctx-migration
# On the destination machine:
ctx config import ~/ctx-migration
ctx doctor

Credentials

Vault and 1Password

Vault and 1Password can supply credentials alongside ctx. Native ctx storage choices are Keychain, file, and pass, with auto selecting a default. The Unix pass store is a separate product from 1Password.

Use 1Password with a process

Let ctx select the client identity and let the 1Password CLI resolve its own references. Prepare a local dotenv file containing references such as SERVICE_TOKEN=op://Client/Service/token and use the vault, item, and field names from your account. Replace your-command with your application.

ctx run -p acme -- op run --env-file=./references.env -- your-command

Use HashiCorp Vault

Authenticate to Vault using your team’s existing method. Vault Agent can render a restricted application configuration file, or a CI job can retrieve values for its child process. Run the application with ctx for its client identity. Avoid configuring the same variable in both sources so precedence is explicit.

Understand reference handling

Writing an op:// URI or a Vault path with ctx secret set stores that literal text. ctx does not authenticate to those services or resolve those references. Use the external tool for retrieval, rotation and audit. For ctx-managed Kubernetes logins, supply keys using a supported local provider.

Hosted documentation

Connect the documentation MCP

Use the public Cloudflare endpoint to search this guide from an MCP client. The hosted service reads published documentation. Cluster login, client knowledge, credentials, and change approvals belong to the separate local ctx mcp server.

Add the remote endpoint

Choose a remote HTTP MCP server in your client and enter the URL below. In Claude Code you can register it with this command. No client profile or cluster password is needed.

claude mcp add --transport http ctx-docs https://ctx-workspace-guide.pages.dev/mcp

Search or read a chapter

Call search_guides with a query such as “Vault”, “trace”, or “SSH”. Use a returned chapter ID with read_guide to retrieve the complete guide. For example, read mcp for local operator setup or enterprise for external secret managers.

Support

Troubleshoot activation

Work from the observed identity to the profile, shell hook or SSH setting that selected it.

The shell shows the wrong client

Compare the active profile, work directory and Git email. Check for a nearer .ctx override and for a manual activation. From the client repository, inspect which Git config file supplied the email.

ctx status
ctx dashboard
git config --show-origin --get user.email

Changing directories does nothing

Transition messages are off by default. Check the actual profile first. If the shell hook is missing, install it, open a new terminal and re-enter the client folder.

ctx doctor
ctx install-hook

GitHub uses the wrong key

Check the origin URL inside the checkout. A client clone uses the profile alias, such as github-acme. Doctor checks the SSH include and verify checks the profile key, alias and live authentication.

git remote -v
ctx doctor
ctx verify acme