This skill should be used when the user asks to "test angreal tasks", "mock angreal", "document tasks", "angreal best practices", "error handling in tasks", "subprocess patterns", "dry run mode", "verbose mode", or needs guidance on testing patterns, development workflows, documentation strategies, or common implementation patterns for angreal tasks.
View on GitHubSelect agents to install to:
npx add-skill https://github.com/angreal/angreal/blob/main/plugin/skills/angreal-patterns/SKILL.md -a claude-code --skill angreal-patternsInstallation paths:
.claude/skills/angreal-patterns/# Angreal Patterns
Common patterns for testing, documenting, and developing angreal tasks.
## Testing Patterns
### Unit Testing Task Functions
```python
# tests/test_build.py
import sys
sys.path.insert(0, ".angreal")
from task_build import build
def test_build_debug_mode():
result = build(release=False)
assert result == 0
def test_build_release_mode():
result = build(release=True)
assert result == 0
```
### Mocking External Commands
```python
from unittest.mock import patch, MagicMock
def test_run_tests_success():
with patch("subprocess.run") as mock_run:
mock_run.return_value = MagicMock(returncode=0)
from task_test import run_tests
result = run_tests()
assert result == 0
```
### Mocking angreal.get_root()
```python
# tests/conftest.py
import pytest
from pathlib import Path
@pytest.fixture
def temp_project(tmp_path):
"""Create temporary project structure."""
angreal_dir = tmp_path / ".angreal"
angreal_dir.mkdir()
(tmp_path / "src").mkdir()
return tmp_path
@pytest.fixture
def mock_root(temp_project, monkeypatch):
"""Mock get_root() to return .angreal/ directory."""
import angreal
angreal_dir = temp_project / ".angreal"
monkeypatch.setattr(angreal, "get_root", lambda: angreal_dir)
return temp_project # Return project root for assertions
```
### Testing Output
```python
def test_task_output(capsys):
from task_status import status
status()
captured = capsys.readouterr()
assert "Project Status" in captured.out
```
## Development Patterns
### Verbose Mode
```python
import angreal
@angreal.command(name="build", about="Build project")
@angreal.argument(name="verbose", short="v", long="verbose",
is_flag=True, takes_value=False)
def build(verbose=False):
if verbose:
print("Starting build...")
do_build()
if verbose:
print("Build complete!")
```
### Quiet Mode
```python
@angreal.command(name="check", a