Skip to content

Commit 61f2522

Browse files
committed
CM-61986-add-windows-path
1 parent 262dd73 commit 61f2522

1 file changed

Lines changed: 28 additions & 2 deletions

File tree

cycode/cli/apps/ai_guardrails/scan/claude_config.py

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,44 @@
1-
"""Reader for ~/.claude.json configuration file.
1+
"""Reader for Claude Code configuration file.
22
33
Extracts user email from the Claude Code global config file
44
for use in AI guardrails scan enrichment.
5+
6+
Config file locations:
7+
- macOS/Linux: ~/.claude.json
8+
- Windows: %APPDATA%/Claude/claude.json (fallback: ~/.claude.json)
59
"""
610

711
import json
12+
import os
13+
import platform
814
from pathlib import Path
915
from typing import Optional
1016

1117
from cycode.logger import get_logger
1218

1319
logger = get_logger('AI Guardrails Claude Config')
1420

15-
_CLAUDE_CONFIG_PATH = Path.home() / '.claude.json'
21+
_CLAUDE_CONFIG_FILENAME = 'claude.json'
22+
23+
24+
def _get_claude_config_path() -> Path:
25+
"""Get Claude config file path based on platform.
26+
27+
Claude Code uses ~/.claude.json on macOS/Linux.
28+
On Windows, checks %APPDATA%/Claude/claude.json first,
29+
then falls back to ~/.claude.json.
30+
"""
31+
if platform.system() == 'Windows':
32+
appdata = os.environ.get('APPDATA')
33+
if appdata:
34+
appdata_path = Path(appdata) / 'Claude' / _CLAUDE_CONFIG_FILENAME
35+
if appdata_path.exists():
36+
return appdata_path
37+
38+
return Path.home() / f'.{_CLAUDE_CONFIG_FILENAME}'
39+
40+
41+
_CLAUDE_CONFIG_PATH = _get_claude_config_path()
1642

1743

1844
def load_claude_config(config_path: Optional[Path] = None) -> Optional[dict]:

0 commit comments

Comments
 (0)