File tree Expand file tree Collapse file tree
cycode/cli/apps/ai_guardrails/scan Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- """Reader for ~/.claude.json configuration file.
1+ """Reader for Claude Code configuration file.
22
33Extracts user email from the Claude Code global config file
44for 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
711import json
12+ import os
13+ import platform
814from pathlib import Path
915from typing import Optional
1016
1117from cycode .logger import get_logger
1218
1319logger = 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
1844def load_claude_config (config_path : Optional [Path ] = None ) -> Optional [dict ]:
You can’t perform that action at this time.
0 commit comments