|
| 1 | +--- |
| 2 | +title: claude-code-project |
| 3 | +description: A reference page for the claude-code-project resource |
| 4 | +--- |
| 5 | + |
| 6 | +The claude-code-project resource manages **per-project** Claude Code configuration. It writes project-scoped instructions, settings, and MCP servers under a specific directory — leaving global configuration untouched. Use it alongside the [`claude-code`](/docs/resources/claude-code/claude-code) resource, which handles installation. |
| 7 | + |
| 8 | +## Parameters |
| 9 | + |
| 10 | +- **directory**: *(string, required)* Path to the project directory. All configuration files are written relative to this path: |
| 11 | + - `<directory>/.claude/CLAUDE.md` |
| 12 | + - `<directory>/.claude/settings.json` |
| 13 | + - `<directory>/.claude.json` |
| 14 | + |
| 15 | +- **claudeMd**: *(string, optional)* Content for `<directory>/.claude/CLAUDE.md`. Accepts inline text, an `https://` URL, or a `codify://documentId:fileId` cloud URL. Claude Code reads this at the start of every session within the project, making it ideal for project-specific conventions, preferred libraries, and review checklists. |
| 16 | + |
| 17 | +- **settings**: *(object, optional)* Key-value pairs to merge into `<directory>/.claude/settings.json`. On apply, the declared keys are written; on destroy, only the declared keys are removed. Supports the same keys as the global settings: |
| 18 | + - `model` — override the default Claude model for this project |
| 19 | + - `effortLevel` — `"low"` | `"medium"` | `"high"` | `"xhigh"` |
| 20 | + - `editorMode` — `"normal"` | `"vim"` |
| 21 | + - `permissions` — `{ allow: [...], deny: [...] }` |
| 22 | + - `env` — environment variables injected into every session |
| 23 | + - `hooks` — lifecycle hooks (PreToolUse, PostToolUse, SessionStart, etc.) |
| 24 | + |
| 25 | +- **mcpServers**: *(array, optional)* MCP servers to register for this project in `<directory>/.claude.json`. Each entry requires a `name` and `type`, plus transport-specific fields: |
| 26 | + - **stdio**: `{ name, type: "stdio", command, args?, env? }` — local process server |
| 27 | + - **http**: `{ name, type: "http", url, headers? }` — remote HTTP (streamable-http) server |
| 28 | + - **sse**: `{ name, type: "sse", url, headers? }` — remote SSE server (deprecated; prefer http) |
| 29 | + |
| 30 | +## Example usage |
| 31 | + |
| 32 | +### Per-project instructions and permissions |
| 33 | + |
| 34 | +```json title="codify.jsonc" |
| 35 | +[ |
| 36 | + { |
| 37 | + "type": "claude-code-project", |
| 38 | + "directory": "~/projects/my-api", |
| 39 | + "claudeMd": "# Project Instructions\n\nThis is a Node.js API. Always use async/await.\nRun `npm test` before committing.", |
| 40 | + "settings": { |
| 41 | + "permissions": { |
| 42 | + "allow": ["Bash(npm run *)", "Bash(git *)"], |
| 43 | + "deny": ["Bash(rm -rf *)"] |
| 44 | + } |
| 45 | + } |
| 46 | + } |
| 47 | +] |
| 48 | +``` |
| 49 | + |
| 50 | +### Per-project instructions with an MCP server |
| 51 | + |
| 52 | +```json title="codify.jsonc" |
| 53 | +[ |
| 54 | + { |
| 55 | + "type": "claude-code-project", |
| 56 | + "directory": "~/projects/my-api", |
| 57 | + "claudeMd": "# Project Instructions\n\nAlways check types with `npm run typecheck` before submitting.", |
| 58 | + "mcpServers": [ |
| 59 | + { |
| 60 | + "name": "project-db", |
| 61 | + "type": "stdio", |
| 62 | + "command": "npx", |
| 63 | + "args": ["-y", "@modelcontextprotocol/server-postgres", "postgresql://localhost/mydb"] |
| 64 | + } |
| 65 | + ] |
| 66 | + } |
| 67 | +] |
| 68 | +``` |
| 69 | + |
| 70 | +### Per-project CLAUDE.md from a remote URL |
| 71 | + |
| 72 | +```json title="codify.jsonc" |
| 73 | +[ |
| 74 | + { |
| 75 | + "type": "claude-code-project", |
| 76 | + "directory": "~/projects/my-api", |
| 77 | + "claudeMd": "codify://my-document-id:my-file-id" |
| 78 | + } |
| 79 | +] |
| 80 | +``` |
| 81 | + |
| 82 | +Or from a public HTTPS URL: |
| 83 | + |
| 84 | +```json title="codify.jsonc" |
| 85 | +[ |
| 86 | + { |
| 87 | + "type": "claude-code-project", |
| 88 | + "directory": "~/projects/my-api", |
| 89 | + "claudeMd": "https://raw.githubusercontent.com/my-org/dotfiles/main/CLAUDE.md" |
| 90 | + } |
| 91 | +] |
| 92 | +``` |
| 93 | + |
| 94 | +### Global install + per-project config together |
| 95 | + |
| 96 | +```json title="codify.jsonc" |
| 97 | +[ |
| 98 | + { |
| 99 | + "type": "claude-code", |
| 100 | + "settings": { |
| 101 | + "model": "claude-opus-4-7" |
| 102 | + } |
| 103 | + }, |
| 104 | + { |
| 105 | + "type": "claude-code-project", |
| 106 | + "directory": "~/projects/my-api", |
| 107 | + "claudeMd": "# My API\n\nNode.js + TypeScript. Run `npm test` before any commit." |
| 108 | + } |
| 109 | +] |
| 110 | +``` |
| 111 | + |
| 112 | +## Notes |
| 113 | + |
| 114 | +- The `claude-code` resource must be applied before `claude-code-project` (it declares a dependency automatically). If Claude Code is not installed, this resource will report as not present. |
| 115 | +- Multiple `claude-code-project` entries can coexist — each unique `directory` is a separate resource instance. |
| 116 | +- Destroying a `claude-code-project` resource removes only the per-project files (`CLAUDE.md`, the declared `settings` keys, and the declared `mcpServers`). The Claude Code binary and global configuration are left untouched. |
| 117 | +- The `settings` parameter merges only the declared keys. Existing project settings not in your Codify config are left untouched. |
| 118 | +- The `claudeMd` parameter manages the entire file. On destroy, the file is removed. |
| 119 | +- MCP servers are stored in `<directory>/.claude.json` under the `mcpServers` key. Removing an MCP server from your config removes it from the file; other servers are untouched. |
0 commit comments