1 ---
2 name: deployment
3 description: Use when the user asks to publish, deploy, or configure deployment settings, deployment geography or regions, or when the user reports their deployed app is broken, asks about production errors, or wants to check server logs.
4 ---
5
6 # Deployment Skill
7
8 Configure deployment settings, publish your project, and debug deployment issues.
9
10 ## When to Use
11
12 Use this skill when:
13
14 - Configuring how the project should run in production
15 - The project is in a working state and ready for publishing
16 - The user explicitly asks to publish or deploy the project
17 - You've completed implementing a feature and verified it works
18 - Setting up deployment for different project types (websites, bots, scheduled jobs)
19 - The user reports their deployed application is not working correctly
20 - The user wants to see what errors are occurring in production
21 - The user needs to debug a runtime issue with their deployed app
22 - The user asks to check deployment or server logs
23 - The user says their app failed to publish or a deployment build failed
24 - After a deployment attempt that the agent initiated fails
25
26 ## When NOT to Use
27
28 - Project has known errors or incomplete features
29 - You haven't validated that the project works
30 - The user is just testing or prototyping
31
32 ## Reference Documents
33
34 This skill has additional reference documents for specific deployment scenarios. Read them as needed:
35
36 - `.local/skills/deployment/references/deployment-logs.md` — How to fetch and analyze runtime deployment logs. Read this when the user's deployed app is misbehaving, the live site is down, or they want to check production logs.
37 - `.local/skills/deployment/references/deployment-failure-debugging.md` — How to diagnose and fix deployment build failures. Read this when the user's deployment build fails to publish, the app crashes during the publishing step, or the user asks for help debugging a deployment error.
38
39 ## Available Functions
40
41 ### deployConfig(deploymentTarget, run, build, publicDir)
42
43 Configure how the project should be deployed to production.
44
45 **Parameters:**
46
47 - `deploymentTarget` (str, required): "autoscale", "vm", "scheduled", or "static"
48 - `run` (list[str], optional): Production run command. First entry is binary/script, rest are arguments
49 - `build` (list[str], optional): Build/compile command before deployment
50 - `publicDir` (str, required for "static"): Directory containing static files
51
52 **Returns:** Dict with `success`, `message`, and configuration details
53
54 **Example:**
55
56 ```javascript
57 // Configure a Python web app
58 const result = await deployConfig({
59 deploymentTarget: "autoscale",
60 run: ["gunicorn", "--bind=0.0.0.0:5000", "--reuse-port", "main:app"]
61 });
62
63 // Configure a static site
64 const result2 = await deployConfig({
65 deploymentTarget: "static",
66 build: ["npm", "run", "build"],
67 publicDir: "dist"
68 });
69
70 // Configure an always-running bot
71 const result3 = await deployConfig({
72 deploymentTarget: "vm",
73 run: ["python", "bot.py"]
74 });
75 ```
76
77 ### suggestDeploy()
78
79 Prompt the user to click the Publish button after the app is ready. **Only works in the main repl context** — in task-agent/subrepl sessions this callback returns `success: false`. If you are in a task agent, skip this call and instead remind the user to publish from the main version after merging.
80
81 ### getDeploymentInfo()
82
83 Fetch the repl's current deployment metadata directly from the deployments service. Always call this — never guess from memory or environment variables — when you need to know whether the project is published, what its production URL is, or whether the live build is healthy. Do NOT run `echo $REPLIT_DOMAINS` to discover the production URL — inside the dev container that variable holds the `.replit.dev` development domain, not the production URL.
84
85 **Returns:** Dict with:
86
87 - `success` (bool): `false` when the deployments service is unreachable. Treat as "deployment status unknown" — tell the user the status is currently unavailable rather than asserting there is no deployment
88 - `isDeployed` (bool): `true` when an active deployment exists for this repl. When `false`, do not fabricate a URL — there is no production URL to give. If the user wants a production URL or asks what their live URL is, guide them through publishing first via the usual deployment flow (e.g. `suggestDeploy()`).
89 - `primaryUrl` (str): fully-qualified production URL with `https://` scheme (a verified custom domain if the user configured one, otherwise the generated `*.replit.app` subdomain). Empty string when not deployed. Use this whenever you need the production URL (e.g. setting a `REPLIT_APP_URL` secret, configuring rewrites in an external CMS, curling the live site, or telling the user where their app is reachable)
90 - `additionalUrls` (list[str]): other public URLs (e.g. additional verified custom domains). Empty list when none
91 - `deploymentType` (str): one of `"autoscale"`, `"vm"`, `"static"`, `"scheduled"`, or `""` if unknown / not applicable. Matches the `deploymentTarget` vocabulary `deployConfig()` accepts
92 - `hasSuccessfulBuild` (bool): `true` only when the deployment's current build is in the `success` status. `false` when the build is still pending, failed, suspended, or no current build exists. When `isDeployed` is `true` but this is `false`, the `primaryUrl` may be unreachable or still be serving a previous successful build — if the user reports the live site is broken, suspect the in-flight or failed build first (see `.local/skills/deployment/references/deployment-failure-debugging.md` for how to investigate)
93 - `visibility` (str): publishing visibility of the current build — `"public"` (reachable by anyone on the internet), `"private"` (invited collaborators only), `"password"` (public URL gated by a shared password), or `""` (undeployed, or a deployment kind with no user-facing visibility). Use this to reason about who can actually reach a leaked secret or vulnerable endpoint
94
95 **Example:**
96
97 ```javascript
98 const info = await getDeploymentInfo();
99 if (!info.success) {
100 console.log("Deployment status unavailable; try again in a moment.");
101 } else if (!info.isDeployed) {
102 console.log("This repl has not been published yet.");
103 } else {
104 console.log(`Live at ${info.primaryUrl} (${info.deploymentType})`);
105 if (!info.hasSuccessfulBuild) {
106 console.log("Current build is not in the success status — URL may be stale.");
107 }
108 }
109 ```
110
111 ### fetchDeploymentLogs({ afterTimestamp, beforeTimestamp, message, messageContext })
112
113 Fetch and analyze deployment logs. See `.local/skills/deployment/references/deployment-logs.md` for full documentation.
114
115 ## Deployment Targets
116
117 Choose the appropriate deployment target based on your project type:
118
119 ### autoscale (Recommended Default)
120
121 Use for stateless websites and APIs that don't need persistent server memory.
122
123 - **Best for:** Web applications, REST APIs, stateless services
124 - **Behavior:** Scales up/down based on traffic, only runs when requests arrive
125 - **State:** Use databases for persistent state (not server memory)
126 - **Cost:** Most cost-effective for variable traffic
127
128 ```javascript
129 await deployConfig({
130 deploymentTarget: "autoscale",
131 run: ["gunicorn", "--bind=0.0.0.0:5000", "app:app"]
132 });
133 ```
134
135 ### vm (Always Running)
136
137 Use for applications that need persistent server-side state or long-running processes.
138
139 - **Best for:** Discord/Telegram bots, WebSocket servers, web scrapers, background workers
140 - **Behavior:** Always running, maintains state in server memory
141 - **State:** Can use in-memory databases, local files, or external databases
142
143 ```javascript
144 await deployConfig({
145 deploymentTarget: "vm",
146 run: ["python", "bot.py"]
147 });
148 ```
149
150 ### scheduled
151
152 Use for cron-like jobs that run on a schedule.
153
154 - **Best for:** Data processing, cleanup tasks, periodic reports, batch jobs
155 - **Behavior:** Runs on configured schedule, not continuously
156 - **Note:** Do NOT use for websites or APIs
157
158 ```javascript
159 await deployConfig({
160 deploymentTarget: "scheduled",
161 run: ["python", "daily_report.py"]
162 });
163 ```
164
165 ### static
166
167 Use for client-side websites with no backend server.
168
169 - **Best for:** Static HTML sites, SPAs (React, Vue, etc.), documentation sites
170 - **Behavior:** Serves static files directly, no server-side processing
171 - **Note:** The `run` command is ignored; must specify `publicDir`
172
173 ```javascript
174 await deployConfig({
175 deploymentTarget: "static",
176 build: ["npm", "run", "build"],
177 publicDir: "dist"
178 });
179 ```
180
181 ## Run Command Examples
182
183 Use production-ready servers, not development servers:
184
185 ```toml
186 # Python with Gunicorn
187 run=["gunicorn", "--bind=0.0.0.0:5000", "--reuse-port", "main:app"]
188
189 # Python with Streamlit
190 run=["streamlit", "run", "main.py"]
191
192 # Node.js
193 run=["node", "server.js"]
194
195 # Multiple processes with bash
196 run=["bash", "-c", "gunicorn --reuse-port -w 4 -b 0.0.0.0:8000 app:app & npm run dev"]
197 ```
198
199 ## Build Command Examples
200
201 Only use build commands when compilation is needed:
202
203 ```toml
204 # TypeScript/bundler
205 build=["npm", "run", "build"]
206
207 # Multiple build steps
208 build=["bash", "-c", "make assets && make compile"]
209
210 # Rust
211 build=["cargo", "build", "--release"]
212 ```
213
214 ## Publishing Geography
215
216 Users can choose the geographic region where their app is published. This is configured in the **Advanced** settings of the Publishing tool, not in code. The agent cannot set this programmatically — the user selects it in the Publishing UI before clicking Publish.
217
218 Key points:
219
220 - **Available on Core, Pro, and Enterprise plans.** Free plan users publish to North America by default.
221 - **Geography is permanent.** Once a project is published to a geography, it cannot be changed. Inform the user of this before they publish for the first time.
222 - **Compute, database, and Object Storage are colocated** in the selected region automatically.
223 - **Enterprise admins can enforce a geography** for all new projects across their organization.
224 - **Available regions may change over time.** For the current list of supported geographies, refer the user to the [Publishing Geography docs](https://docs.replit.com/cloud-services/deployments/publishing-geography).
225
226 If the user asks about deploying to a specific region (e.g. Europe, Asia, Australia):
227
228 - **Not yet published & on Core/Pro/Enterprise:** They can select their preferred geography in the **Advanced** section of the Publishing tool before their first publish.
229 - **Not yet published & on the Free plan:** Geography selection is not available — they will publish to North America by default. They can upgrade their plan to choose a region.
230 - **Already published:** The geography cannot be changed. Let the user know the selection was locked at first publish.
231 - **Enterprise org with enforced geography:** The admin-set geography overrides individual choice. The user publishes to whatever geography their org requires.
232
233 Do **not** tell users that Replit only supports US-based infrastructure — multiple geographies are available.
234
235 ## Best Practices
236
237 1. **Validate before publishing**: Always verify the project works before suggesting publish
238 2. **Use production servers**: Avoid insecure development servers in production
239 3. **Choose the right target**: Match deployment type to your application's needs
240 4. **Configure once**: Set up deployment config early, then suggest publishing when ready
241 5. **Check workflows first**: Ensure workflows are running without errors before publishing
242
243 ## Important Notes
244
245 1. **User-initiated publishing**: The user must click the Publish button to actually deploy
246 2. **Automatic handling**: Publishing handles building, hosting, TLS, and health checks automatically
247 3. **Domain**: Published apps are available at a `.replit.app` domain or custom domain if configured
248 4. **Production config lives in `.replit`**: Deployment settings (run command, build command, deployment target) are in the `.replit` file's `[deployment]` section.
249
250 ## Example Workflow
251
252 ```javascript
253 // 1. Configure deployment settings for a web app
254 await deployConfig({
255 deploymentTarget: "autoscale",
256 run: ["gunicorn", "--bind=0.0.0.0:5000", "app:app"]
257 });
258
259 // 2. After verifying the app works, suggest publishing to the user
260 await suggestDeploy();
261 ```