Coding prompt library

AI Coding Prompts Library

Ready-made coding prompts to copy and adapt, with the required inputs, the expected outputs, the suitable tool and a practical example. Replace what is between the curly braces with your project's details.

4 results

Create a well-structured CLI tool with a package, a configuration file and pytest tests.

Python promptsBeginner
View the prompt
Create a Python command-line tool named {{project}}.
Its job: {{extra}}
Requirements:
- Python 3.11+, a src/ layout with pyproject.toml.
- argparse or Typer (explain the choice), with clear help messages.
- Explicit error handling and correct exit codes, and logging with logging, not print.
- pytest tests that cover normal cases, edge cases and errors.
- A README with install and run commands on Windows and Linux.
Run the tests after writing them and show me the actual result.
Details

Improve the quality of existing Python code by adding types without changing its behaviour.

Python promptsIntermediate
View the prompt
The code is in {{project}} ({{stack}}).
Add type hints gradually:
1. Start with the core modules that depend least on others.
2. Use precise types (TypedDict, Protocol, Literal) instead of Any where possible.
3. Run mypy --strict on each module after changing it, and fix the errors without changing the behaviour.
4. Run the existing tests after each module.
5. Write a summary of the completed and remaining modules and any unresolved errors with their cause.
{{extra}}
Details

Write an asyncio scraping tool that respects robots.txt and rate limits.

Python promptsAdvanced
View the prompt
Write an asynchronous Python tool to collect public data from: {{project}}.
- Use httpx or aiohttp with a concurrency limit (Semaphore) and a delay between requests.
- Respect robots.txt and the site's terms; if they forbid scraping, stop and tell me.
- Retry with exponential backoff for temporary errors only (429, 5xx).
- Parse the pages with selectolax or BeautifulSoup and save the results as JSON Lines.
- Do not collect personal data.
Required fields: {{extra}}
Add tests that use recorded responses instead of the network.
Details

Build a REST API with Pydantic validation, a database and tests.

Python promptsIntermediate
View the prompt
Create a FastAPI API for {{project}}.
- Entities: {{extra}}.
- Separate Pydantic models for input and output, and SQLAlchemy 2.x with Alembic migrations.
- Pagination, correct status codes and uniform errors.
- pytest tests with an isolated test database.
Run the tests and show me the result.
Details