write-tests
/write-tests
Pisze lub ulepsza testy automatyczne, które wykrywają realne błędy, w tym jednostkowe, API, integracyjne i przeglądarkowe.
- Autor
- yaohuangguan ↗
- Repozytorium
- agent-playbook ↗
- Licencja
- MIT
- Ostatnia zmiana repozytorium
- 07.11.2026
Ocena i bezpieczeństwo
- Pliki w paczce
- 13
- Skrypty
- 6
- Komentarze HTML
- 0
- Adresy URL w SKILL.md
- 0
Brak sygnałów. Repozytorium zmienione 07.11.2026, bez odwołań do wycofanych modeli i API.
MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.
- 6 skryptów w paczce. Przejrzyj je przed instalacją, bo Claude może je uruchomić.
Skrypty: examples/go/app.go, examples/go/app_test.go, examples/javascript/app-test.mjs, examples/javascript/app.mjs, examples/python/app.py, examples/python/test_app.py
Co robi i kiedy
Pisze lub ulepsza testy automatyczne, które wykrywają realne błędy, w tym jednostkowe, API, integracyjne i przeglądarkowe.
Oryginalny opis (EN)
Write or improve automated tests that can catch real defects in any language. Use this whenever you add or change tests, including unit, API, integration and browser tests, whenever a feature or bug fix needs test coverage, or whenever someone asks you to raise coverage. It prevents tests that pass without checking anything.
Jak działa
- When to use
- Steps
- Examples
- Permission matrix
- Timing rules
- Stop and ask when
- Common mistakes
- Checklist
- Report
Podgląd SKILL.md
--- name: write-tests description: Write or improve automated tests that can catch real defects in any language. Use this whenever you add or change tests, including unit, API, integration and browser tests, whenever a feature or bug fix needs test coverage, or whenever someone asks you to raise coverage. It prevents tests that pass without checking anything. --- # Write tests A test is only useful if it fails when the code is wrong. Tests that repeat the implementation or mock everything raise the coverage number and catch nothing. ## When to use Any time you add or change a test. To find what is missing in an existing suite, start with `audit-test-suite`. ## Steps 1. **Read the code and a neighbouring test.** Use the project's framework, helpers and naming. Do not add a test framework or a mocking library unprompted. 2. **List what could go wrong.** Before you write code, go through this list and keep every item that applies: - Caller has no credentials, or belongs to someone else - Input is empty, wrong type, at the limit, or one past the limit - Item is missing, or already exists - Dependency times out, errors or returns bad data - The same request arrives twice, or two arrive at once - Time boundary: exactly at the limit, and one unit either side - State is wrong for this action, such as cancelling something finished - A secret or private field could appear in output - Existing users or existing data could change 3. **Choose the level.** Use the highest level that stays fast and repeatable. | Behaviour | Level | | --- | --- | | Pure rule: dates, parsing, limits | Unit test with a table of inputs | | API, permissions, persistence | Real handler, real schema, test database | | Third-party service | Real client code, stubbed at the network | | Multi-step business flow | One ordered scenario through real entry points | | UI behaviour | Browser test against a local app | | Files, processes, OS behaviour | Real OS, on each platform you ship | 4. **Keep your own code real.** Fake only what you do not control: third-party APIs, the clock and platform services. Never mock the function under test or your own modules. Import the real code, never a copy. 5. **Make fakes strict.** An unexpected call must fail the test. A fake that answers anything can hide a wrong URL or an unwanted write. It must also keep the behaviour your code relies on, such as transactions and foreign keys. 6. **Write the test.** Each case sets up its data, does one action, then checks the result. See the example for your language in the next section. 7. **Assert the outcome, not only the response.** - Compare exact values. - Read back stored state after a write. - After a denied or failed call, confirm that nothing changed. - Count side effects: one email, one charge, zero model calls. - Plant a canary secret, then search the output for it. 8. **Prove that the test can fail.** Break the code on purpose, such as by removing the check. Run the test and confirm that it fails **with the expected message**. Restore the code and confirm that it passes. If it still passes while the code is broken, the test is worthless, so fix it. 9. **Confirm it runs in CI.** Find the script or job that executes this file. New files outside the configured pattern are silently never run. 10. **Finish.** Follow `verify-and-report`. ## Examples Open only your language. Each folder has a small API and a complete test, covering permissions, limits, audit records, secrets, replays and concurrency. | Language | Guide | Test file | | --- | --- | --- | | JavaScript, TypeScript | `references/javascript.md` | `examples/javascript/app-test.mjs` | | Python | `references/python.md` | `examples/python/test_app.py` | | Go | `references/go.md` | `examples/go/app_test.go` | For another language, read the closest example and translate it to the project's test framework. ## Permission matrix For each protected operation: | Caller | Expected | Also check | | --- | --- | --- | | No credentials, or forged ones | 401 | Nothing changed | | Valid user, someone else's resource | 404 | Nothing changed, same body as missing | | Member without the required role | 403 | Nothing changed | | Owner | 2xx | Stored value is correct | Use 404 when the caller should not learn that the item exists. Follow the project's convention if it differs. Run the matrix over a list of endpoints, so that a new endpoint is one new row. ## Timing rules - Pass the clock in, and use fixed timestamps for date rules. - Do not use a sleep to wait for work to finish. Wait for a condition. - A deadline only guards against a hang, so make it generous. ## Stop and ask when - The code cannot be tested without a large redesign. - A correct test fails and the expected behaviour is unclear. - Testing would need real credentials or a production system. ## Common mistakes | Tempting move | Why it fails | Do this instead | | --- | --- | --- | | `assert result is not None` | Passes on almost anything | Assert the exact value | | Mock the database and repository | Proves only the mock | Use a real test database | | Copy the implementation's logic into the test | Same bug on both sides | Use known literal values | | Change the expected value to pass | Hides the defect | Find out why it differs | | Check only the response | Misses storage bugs | Read back the stored state | | Test only success | Misses most real incidents | Use the list in step 2 | | Assert on source code text | Breaks on a move, misses behaviour | Run the behaviour | | Snapshot a huge output | Reviewers approve noise | Assert the fields that matter | ## Checklist - [ ] It failed for the right reason when the code was broken. - [ ] It runs real code through a real entry point. - [ ] Unexpected external calls fail the test. - [ ] Denied calls are covered, and they changed nothing. - [ ] Limits are tested on both sides. - [ ] Side effects are counted. - [ ] It does not depend on timing, order or leftover state. - [ ] CI runs it. ## Report ```markdown Tests added: <file: what each case proves> Failure proof: <what you broke, and the failure message> Runs in CI through: <script or job> Not covered: <known gaps> ```
Pliki w paczce (13)
- SKILL.md 6 KB
- examples/go/app.go 4 KB
- examples/go/app_test.go 6 KB
- examples/go/go.mod 1 KB
- examples/javascript/app-test.mjs 5 KB
- examples/javascript/app.mjs 2 KB
- examples/javascript/schema.sql 1 KB
- examples/python/app.py 3 KB
- examples/python/schema.sql 1 KB
- examples/python/test_app.py 5 KB
- references/go.md 2 KB
- references/javascript.md 2 KB
- references/python.md 1 KB
Wersje
| Repozytorium | Wynik | Licencja |
|---|---|---|
| Ta strona · yaohuangguan/agent-playbook | 100 | MIT |
| onsi/biloba | 100 | MIT |
| runwield/runwield | 100 | MIT |
| dzhng/jevgrep | 100 | MIT |
| lukedj78/dev-flow | 100 | MIT |
| dzhng/skills | 100 | MIT |
| rowansci/rowan-python | 100 | MIT |
| microsoft/semantic-link-labs | 100 | MIT |
| qa-aman/claude-skills | 100 | MIT |
Migawka bazy z 13.11.2026 · wersja paczki 7bd83b684c06 (skrót SHA-256 całej paczki)
Pobrania w ostatnich 30 dniach: 0 · ranking
Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.
Podobne skille
- 100writing-tests
Pisze deterministyczne testy, które wykrywają realne błędy produktu, i pomaga naprawiać niestabilne testy. - 100test-unit
Pisze testy jednostkowe i integracyjne dla wskazanego modułu lub zmiany, na przykład dla pojedynczej funkcji. - 100test-generator
Pisze testy jednostkowe i integracyjne dla istniejącego kodu: ścieżki poprawne, błędy i wartości graniczne, w stylu projektu. - 90unit-integration-testing
Pisze testy jednostkowe i integracyjne wokół jednego zachowania, np. błędu, reguły domenowej lub zapisu do bazy. - 84generate-tests
Generuje testy jednostkowe, integracyjne i e2e dla kodu, na przykład dla funkcji, endpointów API czy przepływu zakupowego. - 100unit-testing
Pisze i aktualizuje testy jednostkowe dla nowego lub zmienionego kodu, uruchamia je z pokryciem i naprawia błędy.