Maintain the post-merge setup script that runs automatically after task merges.
After a task is merged, two things run automatically:
.replit and restarts already running workflows.If either step fails, the agent will be alerted about the issue, and should fix it immediately.
The system runs the configured post-merge script from the project root with bash.
Stdin is closed (/dev/null), so commands that prompt for input will get EOF and fail immediately. The full Nix environment is available on PATH.
If the script does not exist, setup fails and you are asked to create it.
The script has a configurable timeout. If the script takes longer, it is killed and setup fails with a timeout error.
After the script, workflow reconciliation syncs running workflows with the current .replit config.
const config = await getPostMergeConfig();
console.log(config);
// { scriptPath: "...", timeoutMs: ... }
Returns the configured script path and timeout from .replit. If not yet configured, both fields will be null.
await setPostMergeConfig({ scriptPath: "scripts/post-merge.sh", timeoutMs: 180000 });
Sets the post-merge script path and/or timeout. Both parameters are optional — only provided values are updated. Note: scriptPath must be set (either already configured or provided in the same call) before setting timeoutMs alone, because .replit requires path in the [postMerge] section. Use timeoutMs when:
npm install, slow migrations), increase the timeout so it succeeds on the next merge. Estimate a reasonable value from the script's expected runtime and add a buffer (e.g. if npm install takes 3s, set timeout to 5000 ms).const result = await runPostMergeSetup();
console.log(result);
Runs the post-merge script and workflow reconciliation. Returns { success, setupError, reconciliationError, scriptPath, stdoutPath, stderrPath, durationMs, timeoutMs }.
setupError / reconciliationError: what failedscriptPath: path to the post-merge script that was executedstdoutPath / stderrPath: full log file pathsdurationMs / timeoutMs: how long it ran and the configured timeoutThe tail of the stdout/stderr log files (last 10 lines with line numbers) is automatically opened into your context after the call.
When setup fails:
scriptPath in the result tells you which script was executed.setPostMergeConfig({ timeoutMs: ... }) based on how long the script actually needs.runPostMergeSetup() to confirm the fix works.If workflow reconciliation fails, use the workflows skill to check and restart affected workflows.
Common failure causes:
scriptPath from the result (or call getPostMergeConfig()) to find the expected path, then create the script there.setPostMergeConfig({ timeoutMs: ... }), or optimize the script.--yes, --force, -y, etc.).Use the scriptPath from the last runPostMergeSetup() result if available. Otherwise, call getPostMergeConfig() to find the script location.
Example:
#!/bin/bash
set -e
pnpm install
pnpm --filter @workspace/db run push-force
Guidelines:
--yes / --force flags.set -e.