Skip to content

Commit ce38fb6

Browse files
abdoutclaude
andcommitted
feat: add per-project DATABASE_URLs to secrets setup
- Updated setup-secrets scripts to handle all gist sections - Added DATABASE_URL_CODEBASE, DATABASE_URL_HOGWARTS, DATABASE_URL_MKAN - Updated documentation with per-project database usage guide - Added shell aliases for switching between project databases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent b53cc72 commit ce38fb6

3 files changed

Lines changed: 97 additions & 32 deletions

File tree

.claude/scripts/setup-secrets.ps1

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,22 +53,42 @@ $EnvContent = @"
5353
# Auto-generated by setup-secrets.ps1
5454
# DO NOT COMMIT THIS FILE
5555
56-
# Required
5756
"@
5857

59-
foreach ($key in $Secrets.required.PSObject.Properties.Name) {
60-
$value = $Secrets.required.$key
61-
if ($value -and -not $value.StartsWith("ghp_xxx") -and -not $value.StartsWith("neon_api_xxx")) {
62-
$EnvContent += "`n$key=$value"
63-
}
64-
}
65-
66-
$EnvContent += "`n`n# Optional"
58+
# Process all sections
59+
$sections = @(
60+
@{Key='required'; Name='Required'},
61+
@{Key='databases'; Name='Databases'},
62+
@{Key='ai'; Name='AI'},
63+
@{Key='auth'; Name='Auth'},
64+
@{Key='services'; Name='Services'},
65+
@{Key='cloudinary'; Name='Cloudinary'},
66+
@{Key='imagekit'; Name='ImageKit'},
67+
@{Key='telegram'; Name='Telegram'},
68+
@{Key='optional'; Name='Optional'}
69+
)
6770

68-
foreach ($key in $Secrets.optional.PSObject.Properties.Name) {
69-
$value = $Secrets.optional.$key
70-
if ($value) {
71-
$EnvContent += "`n$key=$value"
71+
foreach ($section in $sections) {
72+
$sectionData = $Secrets.($section.Key)
73+
if ($sectionData) {
74+
$hasValues = $false
75+
foreach ($key in $sectionData.PSObject.Properties.Name) {
76+
$value = $sectionData.$key
77+
if ($value -and -not $value.StartsWith("ghp_xxx") -and -not $value.StartsWith("neon_api_xxx") -and -not $value.Contains("GET_FROM")) {
78+
$hasValues = $true
79+
break
80+
}
81+
}
82+
if ($hasValues) {
83+
$EnvContent += "# $($section.Name)`n"
84+
foreach ($key in $sectionData.PSObject.Properties.Name) {
85+
$value = $sectionData.$key
86+
if ($value -and -not $value.StartsWith("ghp_xxx") -and -not $value.StartsWith("neon_api_xxx") -and -not $value.Contains("GET_FROM")) {
87+
$EnvContent += "$key=$value`n"
88+
}
89+
}
90+
$EnvContent += "`n"
91+
}
7292
}
7393
}
7494

.claude/scripts/setup-secrets.sh

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -65,25 +65,34 @@ cat > "$ENV_FILE" << 'HEADER'
6565
6666
HEADER
6767

68-
# Parse required secrets
69-
echo "# Required" >> "$ENV_FILE"
68+
# Parse all sections from the gist
7069
echo "$SECRETS" | python3 -c "
7170
import sys, json
7271
data = json.load(sys.stdin)
73-
for key, value in data.get('required', {}).items():
74-
if value and not value.startswith('ghp_xxx') and not value.startswith('neon_api_xxx'):
75-
print(f'{key}={value}')
76-
" >> "$ENV_FILE"
7772
78-
# Parse optional secrets (only non-empty)
79-
echo "" >> "$ENV_FILE"
80-
echo "# Optional" >> "$ENV_FILE"
81-
echo "$SECRETS" | python3 -c "
82-
import sys, json
83-
data = json.load(sys.stdin)
84-
for key, value in data.get('optional', {}).items():
85-
if value:
86-
print(f'{key}={value}')
73+
# Section order for .env file
74+
sections = [
75+
('required', 'Required'),
76+
('databases', 'Databases'),
77+
('ai', 'AI'),
78+
('auth', 'Auth'),
79+
('services', 'Services'),
80+
('cloudinary', 'Cloudinary'),
81+
('imagekit', 'ImageKit'),
82+
('telegram', 'Telegram'),
83+
('optional', 'Optional')
84+
]
85+
86+
for section_key, section_name in sections:
87+
section = data.get(section_key, {})
88+
if section:
89+
has_values = any(v and not str(v).startswith('ghp_xxx') and not str(v).startswith('neon_api_xxx') and 'GET_FROM' not in str(v) for v in section.values())
90+
if has_values:
91+
print(f'# {section_name}')
92+
for key, value in section.items():
93+
if value and not str(value).startswith('ghp_xxx') and not str(value).startswith('neon_api_xxx') and 'GET_FROM' not in str(value):
94+
print(f'{key}={value}')
95+
print()
8796
" >> "$ENV_FILE"
8897

8998
# Set permissions

content/docs/(root)/claude-code.mdx

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,13 +224,49 @@ See full keyword list (90+) in `~/.claude/CLAUDE.md`.
224224
Secrets are stored in a private GitHub gist and auto-loaded via scripts.
225225

226226
### What's Included
227+
228+
**Required**
227229
- `GITHUB_PERSONAL_ACCESS_TOKEN` - GitHub API access
228-
- `NEON_API_KEY` - Neon database MCP
229-
- `DATABASE_URL` - PostgreSQL connection
230+
231+
**Per-Project Databases**
232+
- `DATABASE_URL_CODEBASE` - Codebase project DB
233+
- `DATABASE_URL_HOGWARTS` - Hogwarts (education SaaS) DB
234+
- `DATABASE_URL_MKAN` - Mkan (rental marketplace) DB
235+
- `DATABASE_URL_SOUQ` - Souq (e-commerce) DB (when created)
236+
- `DATABASE_URL_SHIFA` - Shifa (healthcare) DB (when created)
237+
238+
**AI Keys**
230239
- `ANTHROPIC_API_KEY` - Claude API
231240
- `GROQ_API_KEY` - Groq API
241+
242+
**Auth**
232243
- OAuth credentials (Google, Facebook)
233-
- Service keys (Stripe, Resend, Cloudinary, ImageKit)
244+
- `AUTH_SECRET` - NextAuth secret
245+
246+
**Services**
247+
- Stripe, Resend, Cloudinary, ImageKit, Telegram
248+
249+
### Per-Project Database Usage
250+
251+
When working on a specific project, copy the appropriate DATABASE_URL to your project's `.env`:
252+
253+
```bash
254+
# Working on hogwarts?
255+
DATABASE_URL=$DATABASE_URL_HOGWARTS
256+
257+
# Working on mkan?
258+
DATABASE_URL=$DATABASE_URL_MKAN
259+
260+
# Working on codebase?
261+
DATABASE_URL=$DATABASE_URL_CODEBASE
262+
```
263+
264+
Or use an alias in your shell profile:
265+
```bash
266+
alias use-hogwarts='export DATABASE_URL=$DATABASE_URL_HOGWARTS'
267+
alias use-mkan='export DATABASE_URL=$DATABASE_URL_MKAN'
268+
alias use-codebase='export DATABASE_URL=$DATABASE_URL_CODEBASE'
269+
```
234270

235271
### Update Secrets
236272

@@ -244,7 +280,7 @@ Secrets are stored in a private GitHub gist and auto-loaded via scripts.
244280
Create/edit `~/.claude/.env` directly:
245281
```bash
246282
GITHUB_PERSONAL_ACCESS_TOKEN=ghp_xxx
247-
NEON_API_KEY=neon_xxx
283+
DATABASE_URL_HOGWARTS=postgresql://...
248284
# ... other variables
249285
```
250286

0 commit comments

Comments
 (0)