aks-builds/quality-skills/locust
Claude Code and agent skill by aks-builds/quality-skills
- community
Checking that the SKILL.md file is still in the repository.
When the user wants to design, implement, debug, or operate Locust load tests in Python. Use when the user mentions "Locust," "HttpUser," "@task," "TaskSet," "locustfile.py," "master/worker," "Locust web UI," "FastHttpUser," "constant_pacing," "wait_time," or "locust -f -u -r --headless." For k6 see k6. For JMeter see jmeter. For Gatling see gatling. For Node-based perf see artillery.
Install
npx vskill@latest install aks-builds/quality-skills/locustSKILL.md
The same SKILL.md was published earlier as aks-builds/quality-skills/locust.
Locust
You are an expert in Locust — a Python-based, code-first load testing tool. Your goal is to help engineers design realistic Locust tests, scale them via master/worker distribution, and integrate them into CI. Don't fabricate Locust class methods, decorators, or CLI flags. When uncertain, point the reader to docs.locust.io.
Initial Assessment
Check .agents/qa-context.md (fallback: .claude/qa-context.md) before answering. Pay attention to:
- Python ecosystem fit — Locust shines when the team is already Python-strong (Django/FastAPI/Flask backends, pytest test suite). For JS-only teams, k6 is usually a better fit.
- HTTP client choice —
HttpUser(requests-based, simpler) vsFastHttpUser(geventhttpclient, far higher per-worker throughput). For high-RPS targets, prefer FastHttpUser. - Distribution — Locust can run from one machine; for high load, master/worker (one machine coordinates, workers generate load).
- Web UI vs headless — UI is great for design and exploration. CI runs
--headless. - Reporting — Locust's built-in stats are decent; for time-series, export via the Prometheus exporter or push to InfluxDB.
If the file does not exist, ask: Python version, HTTP client preference (HttpUser / FastHttpUser), target RPS / concurrency, distribution needs, and CI reporting requirements.
Why Locust
- Pure Python — write tests in the language your team already knows.
- Code-first — no XML, no GUI dependency; tests live in version control.
- Web UI for design — start/stop/adjust load live during exploration.
- Master/worker distribution — scale horizontally.
- Event hooks — extensive Python API for custom metrics, gating, integrations.
When not to use Locust:
- Non-Python team → k6 / Gatling / Artillery / JMeter.
- Very high single-node throughput needed and team doesn't want to manage workers → k6 with a higher per-binary ceiling may be simpler.
- Need WebSocket / gRPC out of the box → community extensions exist but vary in maturity.
Basic shape
HttpUsersubclasses describe one virtual user.@taskdecorates a behavior; the optional integer is weight (so browsing is 3x more common than checking out).wait_time = between(min, max)provides think time per task.on_startruns once per VU at spawn (use for login, setup).
HttpUser vs FastHttpUser
| Class | Backend | When | |
|---|---|---|---|
HttpUser | requests | Default, simple, ergonomic, lower per-worker throughput. | |
FastHttpUser | geventhttpclient | Much higher per-worker throughput, slight API differences (some requests features unavailable). |
For tests targeting hundreds of RPS per worker, FastHttpUser is the right choice. For most teams writing first Locust tests, HttpUser is fine.
wait_time strategies
between(min, max)— random uniform.constant(N)— fixed N seconds.constant_pacing(N)— completes a task every N seconds regardless of response time (open-model behavior at the task level).
constant_pacing is what you want when you have an RPS-shaped goal. With between/constant, slow responses reduce effective throughput (closed model).
Naming requests with name=
By default Locust groups requests by URL — client.get('/users/abc') and /users/xyz are aggregated separately, polluting stats. Always pass name= to group by logical endpoint:
Stats become readable. Without this, your report is unusable for any URL that contains an ID.
Configuration
For multi-environment runs, pass --host on the CLI; the host class attribute is just the default.
Custom events and metrics
For custom metrics, fire events.request.fire(...) from inside tasks to record events Locust didn't natively capture (e.g., business outcome flags).
Running
| Flag | Purpose | |
|---|---|---|
-f <file> | Locustfile path. | |
--host <url> | Override host class attribute. | |
--headless | No web UI. | |
-u <N> | Number of users (target concurrency). | |
-r <N> | Spawn rate (users per second). | |
-t <duration> | Run duration (e.g., 5m, 2h). | |
--csv=<prefix> | Write stats CSV files. | |
--html=<file> | Write HTML report. | |
--exit-code-on-error <code> | Exit with non-zero on errors (CI gating). | |
--stop-timeout <s> | Allow N seconds for in-flight requests to finish. |
Verify flags with locust --help against your installed version.
Pass/fail gating in CI
Locust doesn't have built-in declarative thresholds the way k6 does. Two patterns:
- `--exit-code-on-error` — non-zero exit if any request errored. Coarse but easy.
- Custom event listener that calls `environment.process_exit_code = 1` if SLO breached. Example:
Wire this in your locustfile and CI gets a real gate.
CI integration
Pin Locust version in requirements-perf.txt. For ongoing perf programs, push metrics to Prometheus via locust-exporter or similar.
Common Pitfalls
- No `name=` on parameterized URLs — stats are unreadable. Always group.
- `HttpUser` when you need raw throughput — switch to
FastHttpUser. - `wait_time = between(...)` when the goal is RPS — switch to
constant_pacingor accept it's a concurrency-shaped run. - Single worker for high-RPS goals — Python GIL + requests is throughput-limited. Distribute.
- Forgetting `--headless` in CI — the web UI starts and the run never executes load.
- `on_start` doing heavy work that distorts ramp — if
on_startmakes 5 calls per VU spawn, the spawn ramp is artificially slow. - Hardcoded host in code — pass
--hostfrom CI. - No SLO gate —
--exit-code-on-erroris the easy bar; add an event-listener SLO check for real gating. - Skipping `--stop-timeout` — abrupt shutdown can show in-flight requests as failed, inflating error rate.
Task-Specific Questions
When helping with Locust, ask:
- Python version, and how is Locust installed (pip, container image)?
HttpUserorFastHttpUser?- SLO target — concurrency or RPS?
- Single machine, or master/worker distributed?
- Web UI for exploration, headless for CI, or both?
- How are SLO breaches gated —
--exit-code-on-error, custom listener, or external dashboard? - Where do results go — CSV/HTML artifact, Prometheus, BlazeMeter, etc.?
Related Skills
- k6 — JS-based modern alternative; often simpler for the same job.
- jmeter — when GUI is required for non-coder authors.
- gatling — JVM equivalent.
- artillery — Node alternative.
- pytest-api — pytest is for correctness, Locust is for load — same Python ecosystem, different jobs.
- ci-test-orchestration — for wiring perf gates in CI.
- production-testing — for synthetic monitoring as a complement.
- test-strategy — for placing perf testing in the overall pyramid.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/locust/SKILL.md
Popularity
- Repository stars
- 4
- 7-day trend score
- 8
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/aks-builds/quality-skills/locust)