Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

chore(tasks): add shell efficiency instruction to agent prompts (#68805)

Charles Vien819f68c3abf6
diff --git a/products/tasks/backend/prompts.py b/products/tasks/backend/prompts.py
index 9ca11bcbb145..316e09bb920a 100644
--- a/products/tasks/backend/prompts.py
+++ b/products/tasks/backend/prompts.py
@@ -1,4 +1,11 @@
-WIZARD_PR_AGENT_PROMPT = """
+SHELL_EFFICIENCY_INSTRUCTION = """\
+Shell efficiency: optimize for the fewest shell round trips.
+- Batch related commands into one Bash invocation using `&&` (e.g. `npm run typecheck && npm run lint && npm test`).
+- Emit all independent tool calls in the same response.
+- Read multiple files at once.
+- Never rerun a command solely to reproduce output you already have."""
+
+WIZARD_PR_AGENT_PROMPT = f"""
PostHog's setup wizard has already run in this repository and integrated PostHog. The working tree
contains its uncommitted changes (modified source files, an updated package manifest, installed
dependencies, a `posthog-setup-report.md` summary, and possibly a `.posthog-events.json` plan).
@@ -45,6 +52,8 @@ Whenever you mention the pull request in any output, summary, or comment, always
full URL (e.g. a Markdown link like [#123](https://github.com/org/repo/pull/123)) rather than plain
text, so readers can open it directly.
+{SHELL_EFFICIENCY_INSTRUCTION}
+
Hard limits: stay strictly within the wizard's changes, plus the changes required to automatically
configure the environment variables in production, plus the minimal fixes needed for CI to pass.
When keeping CI green, do not modify unrelated code, add/remove/upgrade dependencies beyond
diff --git a/products/tasks/backend/temporal/constants.py b/products/tasks/backend/temporal/constants.py
index 933fb1ac1b94..9407deb045bb 100644
--- a/products/tasks/backend/temporal/constants.py
+++ b/products/tasks/backend/temporal/constants.py
@@ -11,6 +11,8 @@ from datetime import timedelta
from django.conf import settings
+from products.tasks.backend.prompts import SHELL_EFFICIENCY_INSTRUCTION
+
# Per-task inactivity timeout defaults (production). User-driven runs — explicitly
# user-created, or with no origin product — get a longer idle grace window since a
# human may still be in the loop; automated/background runs reclaim the sandbox
@@ -96,7 +98,7 @@ MAX_ACK_RETRIES = 5
# flush rate-limits retries.
OUTBOUND_RETRY_BACKOFF = timedelta(seconds=10)
-DEFAULT_CI_MESSAGE = """\
+DEFAULT_CI_MESSAGE = f"""\
You are re-entering this run to address CI feedback on the pull request you opened.
Scope (what to do):
@@ -122,4 +124,6 @@ After fixing, commit and push so CI can re-run.
When you mention the pull request in your summary, always hyperlink it to its full URL (e.g. a
Markdown link like [#123](https://github.com/org/repo/pull/123)) rather than plain text, so readers
can open it directly.
+
+{SHELL_EFFICIENCY_INSTRUCTION}
""".strip()