Skip to content

Commit ad1d383

Browse files
feat: Add claude-code resource (#40)
* feat: Add claude-code resource (auto-generated from issue #39) * feat: added claude code project resource. This can manage any folder. Fix uninstall. * feat: added support for codify files for claude md. * feat: improved deploy script * fix: remove files --------- Co-authored-by: kevinwang5658 <20214115+kevinwang5658@users.noreply.github.com> Co-authored-by: kevinwang <kevinwang5658@gmail.com>
1 parent d94a7fc commit ad1d383

11 files changed

Lines changed: 1151 additions & 2 deletions

File tree

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
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.
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
---
2+
title: claude-code
3+
description: A reference page for the claude-code resource
4+
---
5+
6+
The claude-code resource installs [Claude Code](https://code.claude.com) — Anthropic's agentic coding assistant — and manages its configuration. It handles installation via the official installer script and gives you declarative control over settings, MCP servers, and global instructions.
7+
8+
## Parameters
9+
10+
- **globalClaudeMd**: *(string, optional)* Content to write to `~/.claude/CLAUDE.md`. Claude Code reads this file at the start of every session, making it ideal for global coding standards, preferred libraries, and review checklists that apply to all projects.
11+
12+
- **settings**: *(object, optional)* Key-value pairs to merge into `~/.claude/settings.json`. On apply, the declared keys are written; on destroy, only the declared keys are removed. Common settings include:
13+
- `model` — override the default Claude model
14+
- `effortLevel``"low"` | `"medium"` | `"high"` | `"xhigh"`
15+
- `editorMode``"normal"` | `"vim"`
16+
- `permissions``{ allow: [...], deny: [...] }`
17+
- `env` — environment variables injected into every session
18+
- `hooks` — lifecycle hooks (PreToolUse, PostToolUse, SessionStart, etc.)
19+
- `autoMemoryEnabled` — enable/disable auto memory (default: `true`)
20+
21+
- **mcpServers**: *(array, optional)* MCP servers to register globally in `~/.claude.json`. Each entry requires a `name` and `type`, plus transport-specific fields:
22+
- **stdio**: `{ name, type: "stdio", command, args?, env? }` — local process server
23+
- **http**: `{ name, type: "http", url, headers? }` — remote HTTP (streamable-http) server
24+
- **sse**: `{ name, type: "sse", url, headers? }` — remote SSE server (deprecated; prefer http)
25+
26+
## Example usage
27+
28+
### Install Claude Code with custom settings
29+
30+
```json title="codify.jsonc"
31+
[
32+
{
33+
"type": "claude-code",
34+
"settings": {
35+
"model": "claude-opus-4-7",
36+
"effortLevel": "high",
37+
"editorMode": "vim",
38+
"permissions": {
39+
"allow": ["Bash(npm run *)", "Bash(git *)"],
40+
"deny": ["Bash(rm -rf *)"]
41+
}
42+
}
43+
}
44+
]
45+
```
46+
47+
### Claude Code with global instructions and an MCP server
48+
49+
```json title="codify.jsonc"
50+
[
51+
{
52+
"type": "claude-code",
53+
"globalClaudeMd": "# Global Instructions\n\nAlways follow security best practices.\nPrefer TypeScript over JavaScript.",
54+
"mcpServers": [
55+
{
56+
"name": "filesystem",
57+
"type": "stdio",
58+
"command": "npx",
59+
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"]
60+
}
61+
]
62+
}
63+
]
64+
```
65+
66+
### Claude Code with hooks
67+
68+
```json title="codify.jsonc"
69+
[
70+
{
71+
"type": "claude-code",
72+
"settings": {
73+
"hooks": {
74+
"PostToolUse": [
75+
{
76+
"matcher": "Edit|Write",
77+
"hooks": [
78+
{
79+
"type": "command",
80+
"command": "npx",
81+
"args": ["eslint", "--fix", "${tool_input.file_path}"]
82+
}
83+
]
84+
}
85+
]
86+
}
87+
}
88+
}
89+
]
90+
```
91+
92+
## Notes
93+
94+
- Claude Code is installed via the official installer (`curl -fsSL https://claude.ai/install.sh | bash`) on both macOS and Linux. The binary is placed at `~/.local/bin/claude`.
95+
- The installer adds `~/.local/bin` to your PATH via your shell RC file (`.bashrc` or `.zshrc`). This entry remains after destroy — remove it manually if you no longer want it.
96+
- The `settings` parameter merges only the declared keys. Existing settings not in your Codify config are left untouched.
97+
- The `globalClaudeMd` parameter manages the entire file. On destroy, the file is removed.
98+
- MCP servers are stored in `~/.claude.json` under the `mcpServers` key. Each server's `name` becomes its key in that object. Removing an MCP server from your config removes it from the file; other servers are untouched.
99+
- To see all available settings, run `claude config list` or visit the [settings reference](https://code.claude.com/docs/en/settings).

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "default",
3-
"version": "1.1.2",
3+
"version": "1.2.0",
44
"description": "Default plugin for Codify - provides 50+ declarative resources for managing development tools and system configuration across macOS and Linux",
55
"main": "dist/index.js",
66
"scripts": {

scripts/deploy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,4 +150,4 @@ async function uploadResources(prerelease: boolean) {
150150
.upsert(parameters, { onConflict: 'name,resource_id,prerelease' })
151151
.throwOnError();
152152
}
153-
}
153+
}

src/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ import { FnmResource } from './resources/javascript/fast-node-manager/fast-node-
2424
import { NvmResource } from './resources/javascript/nvm/nvm.js';
2525
import { Pnpm } from './resources/javascript/pnpm/pnpm.js';
2626
import { MacportsResource } from './resources/macports/macports.js';
27+
import { ClaudeCodeResource } from './resources/claude-code/claude-code.js';
28+
import { ClaudeCodeProjectResource } from './resources/claude-code/claude-code-project.js';
2729
import { OllamaResource } from './resources/ollama/ollama.js';
2830
import { PgcliResource } from './resources/pgcli/pgcli.js';
2931
import { Pip } from './resources/python/pip/pip.js';
@@ -108,6 +110,8 @@ runPlugin(Plugin.create(
108110
new SnapResource(),
109111
new TartResource(),
110112
new TartVmResource(),
113+
new ClaudeCodeResource(),
114+
new ClaudeCodeProjectResource(),
111115
new OllamaResource(),
112116
new SyncthingResource(),
113117
new SyncthingDeviceResource(),

0 commit comments

Comments
 (0)