sync_env_from_1password
Skill38 starsChanged 2 months agoMITView on GitHub
Sync Environment Variables from 1Password
- Reads credentials
- Installs packages
In this repository101 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .claude/CLAUDE.mdCLAUDE.md
- .cursor/rules/autonomous_execution.mdcCursor rule
- .cursor/rules/cursor_rules_editing.mdcCursor rule
- .cursor/rules/cursor_rules_sync.mdcCursor rule
- .cursor/rules/cursor_rules_sync_requirement.mdcCursor rule
- site_pages/llms.txtllms.txt
- advisorySkill
- analyzeSkill
- auditSkill
- commitSkill
- create-planSkill
- create_planSkill
- create-prototypeSkill
- create_prototypeSkill
- create_prSkill
- create-releaseSkill
- create_releaseSkill
- create-ruleSkill
- create_ruleSkill
- debugSkill
- draft-illustrationSkill
- draft_illustrationSkill
- endSkill
- evaluate_positioningSkill
- final-reviewSkill
- final_reviewSkill
- fix-feature-bugSkill
- fix_feature_bugSkill
- learnSkill
- manage-error-debuggingSkill
- manage_error_debuggingSkill
- neversight_learn_skills.dev_obviously_awesomeSkill
- process_issuesSkill
- process_prsSkill
- publish-planSkill
- publish_planSkill
- publishSkill
- pullSkill
- pushSkill
- recover_sqlite_databaseSkill
- releaseSkill
- report-errorSkill
- report_errorSkill
- reportSkill
- reviewSkill
- run-feature-workflowSkill
- run_feature_workflowSkill
- setup-commandsSkill
- setup_commandsSkill
- setup-cursor-copiesSkill
- setup_cursor_copiesSkill
- store-neotomaSkill
- store_neotomaSkill
- sync-env-from-1passwordSkill
- analyzeSkill
- auditSkill
- commitSkill
- create-planSkill
- create-prototypeSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
10 rules. About 0 are common, 8 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈8
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 32
Never prints secret values
- Very specific: line 225
Only created if .env file exists
- Distinctive: line 232
Update existing variable or append new one
- Distinctive: line 240
Never prints secret values (only variable names)
- Distinctive: line 249
Problem: Not signed in to 1Password CLI.
- Very specific: line 261
Check MCP server configuration in ~/.cursor/mcp.json
- Distinctive: line 263
Verify 1Password CLI is installed and signed in
- Distinctive: line 284
Verify field has value in 1Password app
- Distinctive: line 285
Check spelling of field name in reference
- Distinctive: line 301
Security first: All security guarantees preserved from original implementation
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
<!-- Source: .cursor/skills/sync-env-from-1password/SKILL.md -->Sync Environment Variables from 1Password
Sync environment variables from 1Password to local .env file using environment variable mappings stored in the truth layer (per neotoma_parquet_migration_rules.mdc).
Command
sync_env_from_1passwordor
sync env from 1passwordPurpose
This command syncs environment variables from 1Password to your local .env file based on mappings stored in the truth layer (per neotoma_parquet_migration_rules.mdc). Parquet path when used: $DATA_DIR/env_var_mappings/env_var_mappings.parquet.
Key features:
- Automatic backup before modification
- Preserves unmanaged environment variables
- Never prints secret values
- Supports environment-based keys (e.g., different API keys for dev/prod)
- Uses 1Password MCP server (preferred) or CLI (fallback)
Prerequisites
Option 1: 1Password MCP Server (Recommended)
Benefits:
- Persistent connection (no session expiration)
- Better error handling
- No repeated authentication
- Consistent with other MCP integrations
Setup:
- Ensure 1Password CLI is installed:
brew install 1password-cli op signin - Configure MCP server in
~/.cursor/mcp.json:{ "mcpServers": { "onepassword": { "command": "bash", "args": [ "/Users/markmhendrickson/repos/ateles/mcp/onepassword/run-onepassword-mcp.sh" ], "env": {} } } } - Verify MCP server is running:
- Restart Cursor after updating mcp.json
- MCP server status visible in Cursor MCP panel
For detailed setup instructions, see: mcp/onepassword/README.md
Option 2: 1Password CLI (Fallback)
When to use:
- MCP server not configured
- Temporary/one-off sync
- Troubleshooting MCP issues
Setup:
- Install 1Password CLI:
brew install 1password-cli - Sign in:
op signin
Note: CLI sessions expire periodically and require re-authentication.
Configuration
Environment Variable Mappings
Mappings are in the truth layer (per neotoma_parquet_migration_rules.mdc). Parquet path when used: $DATA_DIR/env_var_mappings/env_var_mappings.parquet.
Schema:
env_var(string): Environment variable name (e.g.,OPENAI_API_KEY)op_reference(string): 1Password reference (e.g.,op://Personal/API-Keys/openai_token)item_name(string, optional): Friendly name of 1Password itemfield_label(string, optional): Field label in 1Passwordnotes(string, optional): Additional notesenvironment_based(boolean, optional): If true, key varies by environmentenvironment_key(string, optional): Environment identifier (e.g., "development", "production")
Adding/Updating Mappings
Via MCP parquet server:
# Add new mapping
mcp_parquet_add_record(
data_type="env_var_mappings",
record={
"env_var": "MY_API_KEY",
"op_reference": "op://Personal/API-Keys/my_api_key",
"item_name": "API Keys",
"field_label": "my_api_key"
}
)
# Update existing mapping
mcp_parquet_update_records(
data_type="env_var_mappings",
filters={"env_var": "MY_API_KEY"},
updates={"op_reference": "op://Personal/NewItem/field"}
)Via direct parquet editing:
import pandas as pd
from scripts.config import DATA_DIR
# Read mappings
mappings_file = DATA_DIR / "env_var_mappings" / "env_var_mappings.parquet"
df = pd.read_parquet(mappings_file)
# Add or modify rows
# ...
# Write back
df.to_parquet(mappings_file)Environment-Based Keys
For environment-specific keys (e.g., different API keys for dev/prod):
# Development key
{
"env_var": "OPENAI_API_KEY",
"op_reference": "op://Personal/API-Keys/openai_dev",
"environment_based": True,
"environment_key": "development"
}
# Production key
{
"env_var": "OPENAI_API_KEY",
"op_reference": "op://Personal/API-Keys/openai_prod",
"environment_based": True,
"environment_key": "production"
}Set environment:
export ENVIRONMENT=production # or "development"Execution Instructions
Step 1: Verify Prerequisites
If using MCP server:
# Verify MCP server is configured (check ~/.cursor/mcp.json)
# Restart Cursor if you just added the configurationIf using CLI fallback:
# Verify 1Password CLI is installed and signed in
op whoami
# If not signed in: op signinStep 2: Run Sync Command
From repository root:
python execution/scripts/op_sync_env_from_1password.pyOr with custom .env path:
python execution/scripts/op_sync_env_from_1password.py /path/to/.envStep 3: Verify Results
Check output:
- ✓ Backup created (in
.env.backups/) - ✓ Updated keys listed (values NOT shown for security)
- ✓ Sync completed successfully
Check .env file:
# Verify variables were updated (don't print full file - contains secrets)
grep -c "=" .env # Count of variablesBehavior
Backup
Automatic backup before modification:
- Location:
.env.backups/.env-YYYY-MM-DD-HHMMSS - Only created if
.envfile exists - Backup preserves exact file state
Variable Updates
For each mapped variable:
- Resolve secret from 1Password (via MCP or CLI)
- Update existing variable or append new one
- Preserve other variables in
.env(unmanaged variables untouched)
Variables with PLACEHOLDER_ prefix are skipped until configured with actual 1Password references.
Security
Security guarantees:
- Never prints secret values (only variable names)
- Creates backup before modification
- Error messages never expose secrets
- Validates session before proceeding
Error Handling
"1Password CLI is not authenticated"
Problem: Not signed in to 1Password CLI.
Solution:
op signin"MCP failed, falling back to CLI"
Problem: MCP server unavailable or misconfigured.
Solution:
- Check MCP server configuration in
~/.cursor/mcp.json - Restart Cursor after updating configuration
- Verify 1Password CLI is installed and signed in
- Script will automatically fall back to CLI
"Environment variable mappings file not found"
Problem: Mappings file doesn't exist.
Solution:
# Create mappings file structure
mkdir -p $DATA_DIR/env_var_mappings
# Add mappings via MCP parquet server or create parquet file
# See Configuration section above"Empty value returned for 1Password ref"
Problem: Field exists but contains empty value.
Solution:
- Verify field has value in 1Password app
- Check spelling of field name in reference
- Try:
op item get "<item-name>" --format=jsonto see available fields
Related Documentation
mcp/onepassword/README.md- 1Password MCP server documentationexecution/scripts/onepassword_client.py- MCP client implementationexecution/scripts/op_sync_env_from_1password.py- Sync script implementation$DATA_DIR/schemas/env_var_mappings_schema.json- Mappings schema (if exists)
Notes
- MCP preferred over CLI: Script tries MCP first, falls back to CLI automatically
- Persistent connection: MCP eliminates session expiration issues
- Backward compatible: Existing CLI-based workflows continue to work
- No breaking changes: Same interface, enhanced implementation
- Security first: All security guarantees preserved from original implementation
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

