Skip to content

Commit 23f82ec

Browse files
guyskkclaude
andauthored
feat: add claude_args configuration for fixed command-line arguments (#11)
Add a new `claude_args` field to ccc.json that allows users to specify fixed command-line arguments to be passed to Claude Code on every launch. Changes: - Add ClaudeArgs field to Config struct - Modify runClaude to merge configured args with command-line args - Update documentation with examples 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <noreply@anthropic.com>
1 parent fb76ecc commit 23f82ec

File tree

4 files changed

+24
-4
lines changed

4 files changed

+24
-4
lines changed

README-CN.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ $os = "windows"; $arch = if ([Environment]::Is64BitProcess) { "amd64" } else { t
7575
"DISABLE_COST_WARNINGS": "1"
7676
}
7777
},
78+
"claude_args": ["--verbose", "--debug"],
7879
"current_provider": "kimi",
7980
"providers": {
8081
"kimi": {
@@ -107,6 +108,7 @@ $os = "windows"; $arch = if ([Environment]::Is64BitProcess) { "amd64" } else { t
107108

108109
**配置结构:**
109110
- `settings` — 所有提供商共享的基础模板
111+
- `claude_args` — 固定传递给 Claude Code 的参数(可选)
110112
- `current_provider` — 最后使用的提供商(自动更新)
111113
- `providers` — 提供商特定配置
112114

@@ -140,6 +142,11 @@ ccc kimi --help
140142
ccc kimi /path/to/project
141143
```
142144

145+
**说明:** `claude_args` 中配置的参数会自动添加到任何命令行参数之前。例如,如果 `claude_args` 配置为 `["--verbose", "--debug"]`,执行 `ccc kimi --help` 时实际运行的命令是:
146+
```bash
147+
claude --settings ~/.claude/settings-kimi.json --verbose --debug --help
148+
```
149+
143150
### 配置验证命令
144151

145152
`ccc validate` 命令帮助您验证提供商配置:

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ Create `~/.claude/ccc.json`:
7575
"DISABLE_COST_WARNINGS": "1"
7676
}
7777
},
78+
"claude_args": ["--verbose", "--debug"],
7879
"current_provider": "kimi",
7980
"providers": {
8081
"kimi": {
@@ -107,6 +108,7 @@ Create `~/.claude/ccc.json`:
107108

108109
**Config structure:**
109110
- `settings` — Base template shared by all providers
111+
- `claude_args` — Fixed arguments to pass to Claude Code (optional)
110112
- `current_provider` — Last used provider (auto-updated)
111113
- `providers` — Provider-specific overrides
112114

@@ -157,6 +159,11 @@ ccc kimi --help
157159
ccc kimi /path/to/project
158160
```
159161

162+
**Note:** Arguments configured in `claude_args` are automatically prepended to any command-line arguments. For example, if `claude_args` is `["--verbose", "--debug"]` and you run `ccc kimi --help`, the actual command will be:
163+
```bash
164+
claude --settings ~/.claude/settings-kimi.json --verbose --debug --help
165+
```
166+
160167
### Validation Command
161168

162169
The `ccc validate` command helps you verify your provider configurations:

internal/cli/cli.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ func Run(cmd *Command) error {
207207
}
208208

209209
// Run claude with the settings file
210-
if err := runClaude(providerName, mergedSettings, cmd.ClaudeArgs); err != nil {
210+
if err := runClaude(cfg, providerName, mergedSettings, cmd.ClaudeArgs); err != nil {
211211
return fmt.Errorf("error running claude: %w", err)
212212
}
213213

@@ -270,14 +270,19 @@ func determineProvider(cmd *Command, cfg *config.Config) string {
270270
}
271271

272272
// runClaude executes the claude command with the settings file.
273-
func runClaude(providerName string, settings map[string]interface{}, args []string) error {
273+
func runClaude(cfg *config.Config, providerName string, settings map[string]interface{}, args []string) error {
274274
settingsPath := config.GetSettingsPath(providerName)
275275

276276
// Extract ANTHROPIC_AUTH_TOKEN from env
277277
authToken := provider.GetAuthToken(settings)
278278

279-
// Build the claude command
280-
cmdArgs := append([]string{"--settings", settingsPath}, args...)
279+
// Build the claude command: merge configured claude_args with command-line args
280+
var cmdArgs []string
281+
cmdArgs = append(cmdArgs, "--settings", settingsPath)
282+
if len(cfg.ClaudeArgs) > 0 {
283+
cmdArgs = append(cmdArgs, cfg.ClaudeArgs...)
284+
}
285+
cmdArgs = append(cmdArgs, args...)
281286
claudeCmd := exec.Command("claude", cmdArgs...)
282287

283288
// Set up environment variables

internal/config/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ func GetDir() string {
3232
// Settings and Providers use dynamic maps to handle arbitrary Claude settings fields.
3333
type Config struct {
3434
Settings map[string]interface{} `json:"settings"`
35+
ClaudeArgs []string `json:"claude_args,omitempty"`
3536
CurrentProvider string `json:"current_provider"`
3637
Providers map[string]map[string]interface{} `json:"providers"`
3738
}

0 commit comments

Comments
 (0)