Skip to content

Daily Commands

Commands you'll use every day for development.

Git

Status and Inspection

# Status
git status
git status -sb  # Short format with branch

# Log
git log --oneline -10
git log --oneline --graph --all
git log --author="name" --since="1 week ago"

# Diff
git diff                    # Unstaged changes
git diff --staged           # Staged changes
git diff main..feature      # Between branches
git diff HEAD~3..HEAD       # Last 3 commits

Branching

# Create and switch
git checkout -b feature/new-feature
git switch -c feature/new-feature  # Modern alternative

# Switch branches
git checkout main
git switch main

# List branches
git branch              # Local
git branch -r           # Remote
git branch -a           # All
git branch -vv          # With tracking info

# Delete branch
git branch -d feature   # Safe delete
git branch -D feature   # Force delete

Committing

# Stage and commit
git add file.py
git add -p              # Interactive staging
git commit -m "message"
git commit -am "message"  # Stage tracked + commit

# Amend last commit
git commit --amend
git commit --amend --no-edit  # Keep message

# Undo
git restore file.py           # Discard changes
git restore --staged file.py  # Unstage
git reset HEAD~1              # Undo last commit (keep changes)
git reset --hard HEAD~1       # Undo last commit (discard changes)

Remote Operations

# Fetch and pull
git fetch origin
git pull origin main
git pull --rebase origin main

# Push
git push origin feature
git push -u origin feature  # Set upstream
git push --force-with-lease # Safe force push

# Sync with main
git fetch origin
git rebase origin/main

Stashing

git stash                   # Stash changes
git stash -m "description"  # With message
git stash list              # List stashes
git stash pop               # Apply and remove
git stash apply             # Apply and keep
git stash drop              # Remove stash

Advanced

# Interactive rebase
git rebase -i HEAD~3

# Cherry-pick
git cherry-pick abc123

# Bisect
git bisect start
git bisect bad
git bisect good v1.0
# ... test, mark good/bad until found
git bisect reset

# Clean
git clean -n    # Dry run
git clean -fd   # Remove untracked files and directories

Docker

Container Operations

# List
docker ps               # Running
docker ps -a            # All

# Run
docker run -it ubuntu bash
docker run -d -p 8080:80 nginx
docker run --rm -it python:3.12 python

# Stop/Remove
docker stop container_id
docker rm container_id
docker rm -f container_id  # Force

# Logs
docker logs container_id
docker logs -f container_id  # Follow
docker logs --tail 100 container_id

Image Operations

# List
docker images

# Build
docker build -t myapp .
docker build -t myapp:v1.0 .
docker build --no-cache -t myapp .

# Remove
docker rmi image_id
docker image prune      # Remove dangling
docker image prune -a   # Remove unused

Docker Compose

# Start
docker compose up
docker compose up -d      # Detached
docker compose up --build # Rebuild

# Stop
docker compose down
docker compose down -v    # With volumes

# Logs
docker compose logs
docker compose logs -f api

# Execute
docker compose exec api bash
docker compose exec db psql -U postgres

# Restart single service
docker compose restart api

Cleanup

# Remove all stopped containers
docker container prune

# Remove all unused images
docker image prune -a

# Remove all unused volumes
docker volume prune

# Nuclear option
docker system prune -a --volumes

Python (uv)

Project Management

# Initialize project
uv init myproject
cd myproject

# Add dependencies
uv add fastapi sqlalchemy
uv add --dev pytest ruff

# Remove dependency
uv remove package

# Sync dependencies
uv sync

# Update dependencies
uv lock --upgrade
uv sync

Running Commands

# Run script
uv run python script.py

# Run module
uv run python -m pytest
uv run python -m myapp

# Run with environment
uv run --env-file .env python script.py

Virtual Environments

# Create venv
uv venv

# Activate (traditional)
source .venv/bin/activate

# Or use uv run (no activation needed)
uv run python script.py

Node.js (Bun)

Package Management

# Install all
bun install

# Add package
bun add package
bun add -D package  # Dev dependency

# Remove
bun remove package

# Update
bun update
bun update package

Scripts

# Run script
bun run dev
bun dev  # Shorthand

# List scripts
bun run

# Run with filter (monorepo)
bun --filter @app/web dev

Workspace Operations

# Run in all packages
bun --filter '*' run build

# Run in specific package
bun --filter package-name run test

# Install dependency in specific package
bun --filter @app/api add fastify

Testing

pytest

# Run all tests
uv run pytest

# Specific file/directory
uv run pytest tests/test_api.py
uv run pytest tests/unit/

# Specific test
uv run pytest tests/test_api.py::test_create_user
uv run pytest -k "test_create"  # Pattern match

# Options
uv run pytest -v         # Verbose
uv run pytest -x         # Stop on first failure
uv run pytest --lf       # Last failed
uv run pytest --ff       # Failed first
uv run pytest -n auto    # Parallel (pytest-xdist)
uv run pytest --cov=app  # Coverage

JavaScript Testing

# Jest
bun test
bun test -- --watch
bun test -- --coverage

# Vitest
bun test
bun run test:watch
bun run test:coverage

Linting & Formatting

Python (ruff)

# Lint
uv run ruff check .
uv run ruff check . --fix

# Format
uv run ruff format .
uv run ruff format --check .

JavaScript/TypeScript

# ESLint
bun run lint
bun run lint --fix

# Prettier
bun run format
bun run format --check

# Biome (alternative)
bun biome check .
bun biome check --write .

Database

Quick Operations

# Connect
psql -h localhost -U postgres -d sartiq
pgcli -h localhost -U postgres -d sartiq

# Run migrations
uv run alembic upgrade head
uv run alembic downgrade -1

# Create migration
uv run alembic revision --autogenerate -m "Add table"

See Database CLI for comprehensive database commands.

File Operations

Finding Files

# By name (fd is faster than find)
fd "\.py$"
fd -e py -e pyi          # Multiple extensions
fd -H ".env"             # Include hidden

# By content (ripgrep)
rg "TODO"
rg "def create_" -t py
rg "import" -g "*.py"

Viewing Files

# View with syntax highlighting
bat file.py

# View JSON
cat data.json | jq .

# Follow log file
tail -f app.log

# View large file
less +F app.log  # Follow mode, Ctrl+C to stop

Quick Edits

# Open in editor
$EDITOR file.py
code file.py      # VS Code
nvim file.py      # Neovim

# Edit with search
code -g file.py:42  # Go to line 42

Process Management

# Find process
ps aux | grep python
pgrep -f "python app.py"

# Kill process
kill pid
kill -9 pid       # Force
pkill -f "python app.py"

# Port usage
lsof -i :8000
netstat -tlnp | grep 8000

# Kill process on port
kill $(lsof -t -i:8000)

Network

# HTTP requests
curl https://api.example.com/users
curl -X POST -H "Content-Type: application/json" -d '{"name":"test"}' url
curl -s url | jq .  # Silent + parse JSON

# DNS lookup
dig example.com
nslookup example.com

# Port check
nc -zv localhost 5432
telnet localhost 5432

Quick Reference

During Development

g st                    # git status
g co -b feature         # new branch
dc up -d                # start services
uv run pytest -x        # test until fail
pgcli sartiq            # database shell

Debugging

dc logs -f api          # follow logs
dc exec api bash        # shell into container
g diff                  # review unstaged changes

Before PR

uv run ruff check --fix # lint and fix
uv run ruff format .    # format python
bun run lint            # lint frontend
bun run type-check      # type check frontend
g add -p                # interactive stage
g cm "message"          # commit
g push -u origin HEAD   # push new branch