
gravitas-python
GRAVITAS extension for Python projects. Adds Python-specific recon, type checking with mypy/pyright, ruff/flake8 lint, pytest patterns, and common Python failure modes. Load in addition to the base GRAVITAS skill.
- Installs
- 257
- Last 24h
- +11
- Trending rank
- #8520
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/udaysharmadev/gravitas --skill gravitas-python- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads gravitas-python automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
GRAVITAS — Python Extension
Extends the base GRAVITAS skill with Python-specific patterns.
Load skills/gravitas/SKILL.md first, then this file.
Python Recon Additions
□ pyproject.toml — [tool.mypy], [tool.ruff], [tool.pytest.ini_options]
□ setup.py / setup.cfg — legacy config
□ requirements.txt / requirements-dev.txt — dependency versions
□ conftest.py — pytest fixtures (critical for understanding test patterns)
□ __init__.py — package structure
□ Type stubs — are there py.typed markers? stub packages installed?
Read pyproject.toml for type strictness
cat pyproject.toml | grep -A 10 "\[tool.mypy\]"
cat pyproject.toml | grep -A 10 "\[tool.ruff\]"
Python Verification Chain
# Full chain — in this order
mypy . --strict # type correctness
ruff check . # lint (fast, Rust-based)
ruff format --check . # format check
pytest -v --tb=short # all tests
# With coverage
pytest --cov=src --cov-report=term-missing -v
# Type coverage
mypy . --strict 2>&1 | tail -5 # summary line shows error count
Python-Specific Anti-Patterns
Never use bare except
BAD: except:
GOOD: except ValueError as e:
GOOD: except (TypeError, ValueError) as e:
Never shadow builtins
BAD: list = [1, 2, 3] # shadows list()
BAD: id = user.id # shadows id()
GOOD: items = [1, 2, 3]
GOOD: user_id = user.id
Type annotations required (with mypy strict)
BAD: def process(data):
GOOD: def process(data: dict[str, Any]) -> ProcessResult:
Use dataclasses or Pydantic over dicts for structured data
BAD: return {"user_id": 1, "name": "Alice"} # no type safety
GOOD: return UserResponse(user_id=1, name="Alice")
Common Python Failure Modes
| Failure | Root Cause | Fix |
|---|---|---|
Optional[X] has no attribute Y | None not handled | Add if x is not None: guard |
Incompatible return value type | Wrong return type | Check function signature |
Missing return statement | Not all paths return | Add explicit return |
Module has no attribute X | Wrong import | Check module with dir(module) |
Cannot find implementation for X | Missing stub | Install types-X package |
| Circular import | Import at module level | Move to function level or restructure |
Test Patterns (pytest)
Fixture pattern
# conftest.py
import pytest
from myapp.db import get_db
@pytest.fixture
def db():
conn = get_db(":memory:")
yield conn
conn.close()
@pytest.fixture
def client(db):
from myapp import create_app
app = create_app({"TESTING": True})
with app.test_client() as c:
yield c
Standard test structure
class TestUserAuth:
def test_login_success(self, client, db):
# Arrange
db.execute("INSERT INTO users VALUES (1, 'alice', 'hash')")
# Act
response = client.post("/login", json={"username": "alice", "password": "pw"})
# Assert
assert response.status_code == 200
assert response.json["token"] is not None
def test_login_wrong_password(self, client, db):
response = client.post("/login", json={"username": "alice", "password": "wrong"})
assert response.status_code == 401
Parametrize for edge cases
@pytest.mark.parametrize("input,expected", [
("", ValueError),
(None, TypeError),
("valid@email.com", None),
("not-an-email", ValueError),
])
def test_validate_email(input, expected):
if expected:
with pytest.raises(expected):
validate_email(input)
else:
validate_email(input) # should not raise
Framework-Specific Notes
FastAPI
# Always test with TestClient, not raw function calls
from fastapi.testclient import TestClient
client = TestClient(app)
# Type all path/query params and bodies
@router.post("/users", response_model=UserResponse)
async def create_user(body: CreateUserRequest) -> UserResponse:
...
Django
# Use pytest-django
# settings for tests
@pytest.mark.django_db
def test_user_creation():
user = User.objects.create_user(username="test", password="pass")
assert user.id is not None
Quick Reference
# Run single test file
pytest src/auth/test_session.py -v
# Run single test
pytest src/auth/test_session.py::TestSession::test_timeout -v
# Run with pdb on failure
pytest --pdb
# Show slowest tests
pytest --durations=10
# Type check single file
mypy src/auth/session.py --strict
FAQ
What does the gravitas-python skill do?
GRAVITAS extension for Python projects. Adds Python-specific recon, type checking with mypy/pyright, ruff/flake8 lint, pytest patterns, and common Python failure modes. Load in addition to the base GRAVITAS skill.
How do I install gravitas-python?
Run npx skills add https://github.com/udaysharmadev/gravitas --skill gravitas-python in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/gravitas-python/ (personal) or .claude/skills/gravitas-python/ (project).
Which AI agents can use gravitas-python?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is gravitas-python safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains gravitas-python?
It is published by udaysharmadev in udaysharmadev/gravitas. It has 257 recorded installs.
More from udaysharmadev/gravitas
gravitas
udaysharmadev/gravitas
Use for software implementation, debugging, refactoring, review, migration, and other repository-changing engineering work where correctness must be verified. Enforces scoped reconnaissance, adaptive planning, evidence-backed verification, requirement tracking, failure recovery, and budget-aware delegation. Model-agnostic reliability runtime for coding agents -- measured, not claimed.
gravitas-highstakes
udaysharmadev/gravitas
Mandatory checkpoint skill for irreversible/high-stakes changes (schema migrations, file deletion, auth/security changes, production config, force-pushes). Use when a task risks hard-to-reverse damage.
gravitas-typescript
udaysharmadev/gravitas
Open the skill to read its SKILL.md instructions.
Popular testing & qa skills
tdd
mattpocock/skills
Test-driven development. Use when the user wants to build features or fix bugs test-first, mentions "red-green-refactor", or wants integration tests.
grilling
mattpocock/skills
Grill the user relentlessly about a plan, decision, or idea. Use when the user wants to stress-test their thinking, or uses any 'grill' trigger phrases.
migrate-to-shoehorn
mattpocock/skills
Migrate test files from as type assertions to @total-typescript/shoehorn. Use when user mentions shoehorn, wants to replace as in tests, or needs partial test data.
run-train
lllllllama/rigorpilot-skills
Rigor Train skill for deep learning research repositories. Use when a documented or selected training command should be run conservatively for startup verification, short-run verification, full kickoff, or resume, with command, config, seed, log, checkpoint, status, and metric evidence written to standardized trainoutputs/. Do not use for environment setup, exploratory sweeps, speculative idea implementation, or end-to-end orchestration.
test-driven-development
obra/superpowers
Use when implementing any feature or bugfix, before writing implementation code
finishing-a-development-branch
obra/superpowers
Use when implementation is complete, all tests pass, and you need to decide how to integrate the work