write-tests

Write or update unit tests for changed code, following project conventions and ensuring coverage meets the 80% threshold.

16 stars

Best use case

write-tests is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Write or update unit tests for changed code, following project conventions and ensuring coverage meets the 80% threshold.

Teams using write-tests should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/write-tests/SKILL.md --create-dirs "https://raw.githubusercontent.com/JetBrains/databao-cli/main/.claude/skills/write-tests/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/write-tests/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How write-tests Compares

Feature / Agentwrite-testsStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Write or update unit tests for changed code, following project conventions and ensuring coverage meets the 80% threshold.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Write Tests

## Steps

### 1. Identify what to test

Read the source module(s). Focus on:
- Public functions and CLI command handlers
- Branches: error paths, edge cases, validation
- New or changed behavior

Skip: third-party internals, Streamlit UI, trivial pass-throughs.

### 2. Locate or create test file

Tests in `tests/` mirror source modules:

| Source | Test file |
|---|---|
| `src/databao_cli/commands/init.py` | `tests/test_init.py` |
| `src/databao_cli/commands/build.py` | `tests/test_build.py` |
| `src/databao_cli/mcp/tools/<name>.py` | `tests/test_mcp.py` |
| `src/databao_cli/commands/datasource/add.py` | `tests/test_add_datasource.py` |

Add to existing file when possible.

### 3. Conventions

- `pytest` only, no `unittest.TestCase`.
- Use `project_layout` fixture for project dirs, `tmp_path` for filesystem.
- CLI: `click.testing.CliRunner`, import `cli` from `databao_cli.__main__`.
- One behavior per test: `test_<action>_<scenario>`.
- Return type `-> None` on all test functions.
- Mock external I/O, not internal modules.

### 4. Write tests (Arrange/Act/Assert)

Specific assertions over truthiness. Include context:
```python
assert result.exit_code == 0, f"Expected success but got: {result.output}"
```

### 5. Run and verify

```bash
uv run pytest tests/test_<module>.py -v
make test-cov-check
```

Repeat until 80% threshold met.

### 6. Lint

Run `make check`. Fix ruff/mypy errors in test code.

Related Skills

update-pr

16
from JetBrains/databao-cli

Stage, commit, and push follow-up changes to an existing feature branch or PR. Use for quick iterations.

setup-environment

16
from JetBrains/databao-cli

Set up or verify the local development environment. Use when starting work in a fresh clone or new machine, when commands fail with missing dependencies or broken imports, or before running `make check`/`make test` for the first time in a session.

review-architecture

16
from JetBrains/databao-cli

Review architecture quality, maintainability, and developer experience.

make-yt-issue

16
from JetBrains/databao-cli

Ensure a YouTrack issue exists before starting work. Validates existing tickets or creates new ones.

local-code-review

16
from JetBrains/databao-cli

Review local code changes for correctness, regressions, missing tests, and Databao-specific risks.

eval-skills

16
from JetBrains/databao-cli

Run structured evaluations on skills to measure quality and track improvements.

create-pr

16
from JetBrains/databao-cli

Stage, commit, push, and open a GitHub PR following project conventions. Use when code is ready to ship.

create-branch

16
from JetBrains/databao-cli

Create a feature branch following project naming conventions. Use when starting work on a ticket, after understanding the scope, or when the agent needs to branch off main for new work.

check-pr-comments

16
from JetBrains/databao-cli

Fetch unresolved PR review threads, triage them, implement fixes, validate, reply in-thread, and resolve.

check-coverage

16
from JetBrains/databao-cli

Run test coverage measurement, analyze results, and fix gaps when coverage falls below the 80% threshold.

autosteer

16
from JetBrains/databao-cli

Run the full development pipeline autonomously without pausing between phases. Stops only on quality-gate failures.

content-research-writer

16
from plurigrid/asi

Assists in writing high-quality content by conducting research, adding