profile

package
v0.2.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 14, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package profile generates the per-provider JSON files that Claude Code loads via its `--settings` flag (a.k.a. profiles).

One file per provider lives at ~/.claude/profiles/<provider>.json with mode 0600. The file pins two things — the apiKeyHelper command that fetches the key on demand, and the ANTHROPIC_BASE_URL env var that routes traffic to the provider's Anthropic-compatible endpoint. Everything else inherits from the user's ~/.claude/settings.json via Claude Code's normal settings merge.

Profiles intentionally do NOT follow XDG: Claude Code reads ~/.claude/ unconditionally, so this package roots everything under the user's home directory.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateForProvider added in v0.1.9

func GenerateForProvider(v *config.Provider, helperBinary string) ([]byte, error)

GenerateForProvider renders the profile JSON for v.

helperBinary is the absolute path that will be written into the apiKeyHelper field; callers normally pass os.Executable() so the helper invocation stays bound to the same cc-fleet binary that wrote the profile. An empty helperBinary is an error here — WriteForProvider resolves os.Executable() before delegating.

The output is 2-space indented and has no trailing newline.

func ProfilePath

func ProfilePath(provider string) (string, error)

ProfilePath returns the absolute path to <ProfilesDir>/<provider>.json.

provider must be a non-empty plain provider name (e.g. "deepseek").

Defense-in-depth: provider is validated against the path/shell-safe grammar AND the constructed path is checked to stay under ProfilesDir, so even a malformed name that slipped past config Load can't escape ~/.claude/profiles/.

func ProfilesDir

func ProfilesDir() (string, error)

ProfilesDir returns the absolute path to ~/.claude/profiles/.

It errors if the user's home directory cannot be resolved; the directory is not created here — writers (WriteForProvider) MkdirAll it on demand.

func RemoveForProvider added in v0.1.9

func RemoveForProvider(provider string) error

RemoveForProvider deletes the profile file for provider.

A missing file is NOT an error — this is intended for idempotent cleanup from teardown / uninstall paths.

func WriteForProvider added in v0.1.9

func WriteForProvider(v *config.Provider, helperBinary string) (string, error)

WriteForProvider writes the profile for v to ProfilePath(v.Name) atomically with mode 0600. The parent directory is created on demand at mode 0700.

If helperBinary is empty, os.Executable() is used so the apiKeyHelper field always carries an absolute path to the running binary.

Returns the resolved profile path on success.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL