Expert guide for pypet - a modern Python command-line snippet manager with Git sync, clipboard integration, and shell aliases. Helps with testing, code quality, architecture understanding, and following project conventions.
A specialized skill for working with pypet, a modern Python command-line snippet manager with Git synchronization, clipboard integration, and shell alias management.
This skill helps you work effectively with the pypet codebase by:
1. **Models** (`pypet/models.py`): `Snippet` and `Parameter` dataclasses with TOML serialization
2. **Storage** (`pypet/storage.py`): TOML-based persistence at `~/.config/pypet/snippets.toml`
3. **CLI** (`pypet/cli/*.py`): Click-based interface with Rich formatting, organized into modules
4. **Sync** (`pypet/sync.py`): Git-based synchronization with automatic backups
5. **Alias Manager** (`pypet/alias_manager.py`): Shell alias management for bash/zsh
When starting work:
**Use these commands in order of preference:**
```bash
make test-quick
make test
pytest -v
pytest tests/test_models.py
pytest tests/test_models.py::test_snippet_initialization
```
**Important:** All 130 tests must pass before any release.
**Always run before committing:**
```bash
make format
make lint
make all
```
**Note:** Ruff is used for both formatting and linting. Pre-push hooks enforce this automatically.
```bash
make dev
make install # Install package in dev mode
make hooks # Install pre-push git hooks
pypet --help
```
**Follow this pattern to avoid circular imports:**
1. Create command in appropriate module (e.g., `cli/snippet_commands.py`)
2. Import main from `.main`: `from .main import main`
3. Register with decorator: `@main.command()`
4. Import module in `cli/__init__.py` to trigger registration
5. Add tests in corresponding `tests/test_*_cli.py` file
**Example:**
```python
from .main import main
@main.command()
def my_command():
"""Command description."""
pass
```
Tests are organized by component:
**Use Click's `CliRunner` for CLI tests:**
```python
from click.testing import CliRunner
runner = CliRunner()
result = runner.invoke(command, args)
```
**Follow these strictly:**
**Important guidelines:**
**Common issues:**
1. **Never skip tests in production**: All 130 tests must pass
2. **Always format before commit**: Use `make format` or pre-push hooks will fail
3. **Respect module organization**: Don't bypass the CLI module structure
4. **Maintain backward compatibility**: TOML format changes must migrate existing data
5. **Use atomic operations**: Storage operations must be thread-safe
**Scenario: Adding a new snippet command**
1. Determine appropriate module (e.g., `cli/snippet_commands.py`)
2. Read existing commands in that module for patterns
3. Implement command following Click conventions
4. Add corresponding tests in `tests/test_cli.py`
5. Run `make format` to auto-format
6. Run `make test-quick` to verify
7. Run `make all` before committing
**Scenario: Fixing a test failure**
1. Run `pytest -v tests/test_failing.py` for detailed output
2. Fix the issue in the relevant module
3. Run `make format` to ensure formatting is correct
4. Run `pytest tests/test_failing.py` to verify fix
5. Run `make test` to ensure no regressions
**Scenario: Understanding sync feature**
1. Read `pypet/sync.py` for implementation
2. Review `tests/test_sync.py` for usage examples
3. Check `cli/sync_commands.py` for CLI interface
4. Understand backup/restore flow in Storage class
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/pypet-cli-development-assistant/raw