Skip to main content

ctx generate instruction

Generate project instructions.

Instruction (i)​

Options​

optionsshorthandrequireddescription
--overwriteOverwrite the existing instruction file.
--pathRelative markdown file path to write.
--presetInstruction preset to write.
--help-hShow this help message and exit.
--version-VPrint version information and exit.

What it does​

Generates an instruction file that helps an AI agent work with CTX in a project.

The generated instructions explain how the agent should use CTX and work with the project's context. They are static instructions for the AI and are separate from the project's sessions, tasks, logs, and decisions.

You can generate the instruction file for a supported AI tool or provide your own relative file path.

When to use it​

Use this command when you want to add CTX instructions to an AI-assisted development workflow.

A preset is useful when the AI tool already has a conventional location for project instructions. Use --path when you want to place the instructions at a specific location.

How it works​

The command writes the generated instructions as a Markdown file in the project.

You can choose how the file is generated by providing either a preset or a path.

presetoutput file
firebaseairrules.md
copilot.github/copilot-instructions.md
cursor.cursor/rules/instructions.md
jetbrains.junie/guidelines.md
vscode.instructions.md
windsurf.windsurf/rules/instructions.md
codexAGENTS.md
claudeCLAUDE.md

The existing instruction file is not overwritten unless --overwrite is provided.

The command expects either --preset or --path to determine where the instructions should be written.

info

The generated instruction is the static guidance for an AI agent on how to use CTX. It is not the project's execution context itself.

For a deeper explanation of CTX instructions and how they work with AI, see Instruction.

Examples​

Generate instructions for Codex​

ctx generate instruction --preset=codex

Creates AGENTS.md with CTX instructions for Codex.

Generate instructions for GitHub Copilot​

ctx generate instruction --preset=copilot

Creates .github/copilot-instructions.md with CTX instructions for GitHub Copilot.

Write instructions to a custom path​

ctx generate instruction --path=.ai/ctx-instructions.md

Writes the generated instructions to the specified relative Markdown path.

Overwrite an existing instruction file​

ctx generate instruction --preset=codex --overwrite

Replaces the existing instruction file with the generated instructions.