Use Autohand Code to follow route handlers, data access, logs, traces, and test coverage before making a focused performance change.
Trace latency before changing code
Performance Delivery and operations Operate Analysis
autohand -p "Trace why this endpoint is slow and propose the smallest safe optimization"
A bottleneck analysis, focused optimization, and before/after verification plan.
Optimize a slow endpoint with Autohand Code is a performance workflow that traces a slow request path, finds the likely bottleneck, and proposes or applies the smallest measured optimization. ### At a glance | Question | Answer | | --- | --- | | Best for | slow API routes, expensive database queries, repeated network calls, serialization cost, and handlers with unclear latency sources | | Primary inputs | Endpoint, request shape, latency target, and recent production or staging evidence; Logs, traces, query plans, profiles, or timing screenshots; Relevant route handlers, data access code, caches, and test commands | | Autohand Code returns | A bottleneck analysis, focused optimization, and before/after verification plan. | | Avoid when | there is no baseline measurement, no target endpoint, or no safe way to validate behavior after the change | ### How Autohand Code handles this workflow 1. Maps the route from entry point to data access and external calls. 2. Separates observed latency from guesses before editing code. 3. Identifies the lowest-risk optimization and the behavior it must preserve. 4. Returns before-and-after evidence or a concrete measurement plan when local proof is unavailable. ### Best inputs - Endpoint, request shape, latency target, and recent production or staging evidence - Logs, traces, query plans, profiles, or timing screenshots - Relevant route handlers, data access code, caches, and test commands ### Strong prompt autohand -p "Trace why this endpoint is slow and propose the smallest safe optimization" ### Autohand Code CLI options - Run `autohand -p "Trace why this endpoint is slow and propose the smallest safe optimization"` with endpoint evidence and a latency target. - Use `--restricted` for the first investigation pass if traces or logs contain sensitive data. - Use `/mcp` to connect approved observability, database, or profiling tools when local files are not enough. ### Review before accepting Reviewers should see the measured baseline, chosen bottleneck, changed code, and a safe way to compare the result. ### Source and validation signals Autohand AI maintains this workflow as first-party product guidance for Autohand Code. Use the [Autohand CLI Playbook](https://github.com/autohandai/code-cli/blob/main/docs/AUTOHAND_PLAYBOOK.md), [CLI reference](/docs/working-with-autohand-code/cli-reference.html), and [configuration reference](https://github.com/autohandai/code-cli/blob/main/docs/config-reference.md) when choosing between interactive mode, command mode, auto-mode, feature-enabled /goal, /settings, skills, MCP, and permission settings. The related resources below link to product docs and tutorials for the workflow, and the final answer should name repository-specific files, commands, outputs, or docs that a reviewer can verify. ### Frequently asked questions ### What is Optimize a slow endpoint with Autohand Code? Optimize a slow endpoint with Autohand Code is a performance workflow that traces a slow request path, finds the likely bottleneck, and proposes or applies the smallest measured optimization. ### When should a team use Optimize a slow endpoint? Use it when a route is slow but the code path, data access pattern, or validation strategy is unclear. ### What evidence should reviewers check for Optimize a slow endpoint? Reviewers should see the measured baseline, chosen bottleneck, changed code, and a safe way to compare the result.
Guide Observability Use signals and traces to understand runtime behavior. /docs/guides/sre/observability.html Guide Troubleshooting Collect evidence before changing production-sensitive code. /docs/guides/troubleshooting.html Guide Cost Optimization Reduce expensive work while keeping behavior measurable. /docs/guides/cost-optimization.html