1 ---
2 name: environment-secrets
3 description: Manage environment variables and secrets. View, set, delete env vars and request secrets from users.
4 ---
5
6 # Environment Secrets Skill
7
8 Manage environment variables and secrets (such as API keys, tokens, and credentials). View, set, delete environment variables and request secrets from users.
9
10 The user can also change the values of any environment variables/secrets using the "secrets" tab in the Replit GUI.
11
12 ## When to Use
13
14 Use this skill when:
15
16 - You need to check what environment variables or secrets exist
17 - Setting sensitive configuration values (ports, hostnames, feature flags)
18 - Deleting obsolete environment variables
19 - Requesting API keys, tokens, or other secrets from the user
20
21 ## When NOT to Use
22
23 - Never set sensitive values directly (API keys, passwords, tokens) - always use `requestEnvVar` to request from user
24 - Don't modify runtime-managed variables (REPLIT_DOMAINS, REPL_ID, DATABASE_URL for Helium DBs)
25
26 ## Environment Types
27
28 Environment variables are scoped to specific environments:
29
30 - **shared**: Available in both development and production
31 - **development**: Only available in development environment
32 - **production**: Only available in production environment
33
34 By default, you should use the 'shared' environment to store environment variables unless there is a clear reason why it would require different values in development and production.
35
36 An environment variable stored in the 'shared' environment can not be modified in 'development' or 'production' environments. To modify it, delete it from the 'shared' environment and re-add it to 'development' and 'production' environments.
37
38 Secrets are global and not environment-scoped.
39
40 ## Available Functions
41
42 ### viewEnvVars(type, environment, keys)
43
44 View environment variables and/or secrets.
45
46 **Parameters:**
47
48 - `type` (str, default "all"): What to view: "env", "secret", or "all"
49 - `environment` (str, optional): Filter by environment: "shared", "development", "production"
50 - `keys` (list[str], optional): Filter by specific keys
51
52 **Returns:** Dict with `envVars`, `secrets`, and `runtimeManaged` fields
53
54 **Example:**
55
56 ```javascript
57 // View all env vars and secrets
58 const result = await viewEnvVars();
59 console.log(result.envVars); // {shared: {PORT: '3000'}, development: {...}}
60 console.log(result.secrets); // {OPENAI_API_KEY: true, STRIPE_KEY: true}
61
62 // Check if specific secrets exist
63 const result2 = await viewEnvVars({ type: "secret", keys: ["OPENAI_API_KEY", "STRIPE_KEY"] });
64 if (result2.secrets.OPENAI_API_KEY) {
65 console.log("OpenAI key is configured");
66 }
67
68 // View only development env vars
69 const result3 = await viewEnvVars({ type: "env", environment: "development" });
70 ```
71
72 ### setEnvVars(values, environment)
73
74 Set environment variables. Cannot be used for secrets.
75
76 **Parameters:**
77
78 - `values` (dict[str, str], required): Key-value pairs to set
79 - `environment` (str, default "shared"): Target: "shared", "development", "production"
80
81 **Returns:** Dict with `environment` and `keys` that were set
82
83 **Example:**
84
85 ```javascript
86 // Set shared config (available in dev and prod)
87 await setEnvVars({ values: { PORT: "3000", DEBUG: "false" } });
88
89 // Set development-only config
90 await setEnvVars({ values: { LOG_LEVEL: "debug" }, environment: "development" });
91
92 // Set production config
93 await setEnvVars({ values: { LOG_LEVEL: "error" }, environment: "production" });
94 ```
95
96 ### deleteEnvVars(keys, environment)
97
98 Delete environment variables.
99
100 **Parameters:**
101
102 - `keys` (list[str], required): Keys to delete
103 - `environment` (str, default "shared"): Target: "shared", "development", "production"
104
105 **Returns:** Dict with `environment` and `keys` that were deleted
106
107 **Example:**
108
109 ```javascript
110 // Delete from shared environment
111 await deleteEnvVars({ keys: ["OLD_CONFIG", "DEPRECATED_FLAG"] });
112
113 // Delete from specific environment
114 await deleteEnvVars({ keys: ["DEBUG"], environment: "development" });
115 ```
116
117 ### requestEnvVar(requestType, keys, envVars, userMessage)
118
119 Request secrets or environment variables from the user. This pauses agent execution until the user provides the values.
120
121 **Parameters:**
122
123 - `requestType` (str, required): "secret" or "env"
124 - `keys` (list[str], required if requestType="secret"): Secret keys to request
125 - `envVars` (list[dict], required if requestType="env"): Env vars with `key` and `environment`
126 - `userMessage` (str, optional): Custom message for user
127
128 **Returns:** Dict with `requested`, `userMessage`, and `waitingForInput`
129
130 **Example - Request secrets:**
131
132 ```javascript
133 // Request API keys from user
134 await requestEnvVar({
135 requestType: "secret",
136 keys: ["OPENAI_API_KEY", "STRIPE_SECRET_KEY"],
137 userMessage: "Please provide your API keys to enable the payment feature"
138 });
139 // Agent pauses here until user provides the secrets
140 ```
141
142 **Example - Request env vars:**
143
144 ```javascript
145 // Request non-sensitive config from user
146 await requestEnvVar({
147 requestType: "env",
148 envVars: [
149 { key: "CUSTOM_DOMAIN", environment: "production" },
150 { key: "FEATURE_FLAG", environment: "shared" }
151 ],
152 userMessage: "Please provide the following configuration values"
153 });
154 ```
155
156 ## Best Practices
157
158 1. **Check before requesting**: Always use `viewEnvVars` first to see what's already configured
159 2. **Use shared for common config**: Put variables needed in both dev and prod in "shared"
160 3. **Never hardcode secrets**: Always request secrets from users via `requestEnvVar`
161 4. **Provide helpful messages**: Include context when requesting secrets so users know why they're needed
162 5. **Handle conflicts**: If you need to move a var between environments, delete from old first
163
164 ## Example Workflow
165
166 ```javascript
167 // 1. Check current configuration
168 const result = await viewEnvVars();
169
170 // 2. Check if required secrets exist
171 const missingSecrets = [];
172 for (const key of ["OPENAI_API_KEY", "DATABASE_URL"]) {
173 if (!result.secrets[key]) {
174 missingSecrets.push(key);
175 }
176 }
177
178 // 3. Request missing secrets from user
179 if (missingSecrets.length > 0) {
180 await requestEnvVar({
181 requestType: "secret",
182 keys: missingSecrets,
183 userMessage: "The following API keys are needed for the chat feature"
184 });
185 } else {
186 // 4. Set non-sensitive config
187 await setEnvVars({
188 values: {
189 CHAT_ENABLED: "true",
190 MAX_TOKENS: "4096"
191 }
192 });
193 }
194 ```
195
196 ## Restrictions
197
198 - Cannot view secret values (only existence status)
199 - Cannot set or modify secrets directly
200 - Cannot modify runtime-managed variables
201 - Variables cannot exist in both "shared" and a specific environment simultaneously