Skip to content
This repository was archived by the owner on Feb 20, 2026. It is now read-only.

Commit 8d00860

Browse files
jlaustillclaude
andcommitted
Add global config support (~/.config/claude-sandbox/config.json)
Config priority: defaults < global < local project config This allows setting dockerImage globally without modifying code: mkdir -p ~/.config/claude-sandbox echo '{"dockerImage": "docker-devbox:latest"}' > ~/.config/claude-sandbox/config.json Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 782efeb commit 8d00860

2 files changed

Lines changed: 33 additions & 14 deletions

File tree

src/config.ts

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ import path from "path";
33
import os from "os";
44
import { SandboxConfig } from "./types";
55

6+
// Global config location: ~/.config/claude-sandbox/config.json
7+
const GLOBAL_CONFIG_PATH = path.join(
8+
os.homedir(),
9+
".config",
10+
"claude-sandbox",
11+
"config.json"
12+
);
13+
614
const DEFAULT_CONFIG: SandboxConfig = {
715
dockerImage: "claude-code-sandbox:latest",
816
autoPush: true,
@@ -17,27 +25,38 @@ const DEFAULT_CONFIG: SandboxConfig = {
1725
// bashTimeout: 600000, // 10 minutes
1826
};
1927

20-
export async function loadConfig(configPath: string): Promise<SandboxConfig> {
28+
async function loadJsonFile(filePath: string): Promise<Partial<SandboxConfig> | null> {
2129
try {
22-
const fullPath = path.resolve(configPath);
23-
const configContent = await fs.readFile(fullPath, "utf-8");
24-
const userConfig = JSON.parse(configContent);
25-
26-
// Merge with defaults
27-
return {
28-
...DEFAULT_CONFIG,
29-
...userConfig,
30-
};
31-
} catch (error) {
32-
// Config file not found or invalid, use defaults
33-
return DEFAULT_CONFIG;
30+
const content = await fs.readFile(filePath, "utf-8");
31+
return JSON.parse(content);
32+
} catch {
33+
return null;
3434
}
3535
}
3636

37+
export async function loadConfig(configPath: string): Promise<SandboxConfig> {
38+
// Load global config first (if exists)
39+
const globalConfig = await loadJsonFile(GLOBAL_CONFIG_PATH);
40+
41+
// Load local project config (if exists)
42+
const localConfig = await loadJsonFile(path.resolve(configPath));
43+
44+
// Merge: defaults < global < local
45+
return {
46+
...DEFAULT_CONFIG,
47+
...(globalConfig || {}),
48+
...(localConfig || {}),
49+
};
50+
}
51+
3752
export async function saveConfig(
3853
config: SandboxConfig,
3954
configPath: string,
4055
): Promise<void> {
4156
const fullPath = path.resolve(configPath);
4257
await fs.writeFile(fullPath, JSON.stringify(config, null, 2));
4358
}
59+
60+
export function getGlobalConfigPath(): string {
61+
return GLOBAL_CONFIG_PATH;
62+
}

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ export class ClaudeSandbox {
212212
credentials,
213213
workDir,
214214
repoName,
215-
dockerImage: this.config.dockerImage || "claude-sandbox:latest",
215+
dockerImage: this.config.dockerImage || "claude-code-sandbox:latest",
216216
prFetchRef,
217217
remoteFetchRef,
218218
};

0 commit comments

Comments
 (0)