debugging-streamlit
Debug Streamlit frontend and backend with integrated hot-reload and logging.
Install
mkdir -p .claude/skills/debugging-streamlit && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/1442" && unzip -o skill.zip -d .claude/skills/debugging-streamlit && rm skill.zipInstalls to .claude/skills/debugging-streamlit
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Debug Streamlit frontend and backend changes using make debug with hot-reload. Use when testing code changes, investigating bugs, checking UI behavior, or needing screenshots of the running app.Key capabilities
- →Start backend and frontend servers simultaneously
- →Enable hot-reload for frontend and app scripts
- →Manage per-session log files
- →Execute automated Playwright UI tests
- →Capture full-page or element screenshots
How it works
The skill uses make debug to launch both servers, providing a unified logging directory and utilities for automated UI interaction and screenshot capture.
Inputs & outputs
When to use debugging-streamlit
- →Debug Streamlit bugs
- →Test code changes
- →Review frontend logs
About this skill
Debugging Streamlit Apps
Quick Start
make debug my_app.py
This starts both backend (Streamlit/Python) and frontend (Vite/React) with hot-reload. The app URL is printed on startup (default http://localhost:3001; 3000 is reserved for manual make frontend-dev; it may use 3002+ if other debug sessions are running). Avoid pinning VITE_PORT unless you have a specific hard requirement (last resort).
Hot-reload behavior:
- Frontend: Changes to
frontend/code are applied within seconds. - Backend: Only changes to the app script trigger a rerun. Changes to the Streamlit library itself (
lib/streamlit/) require restartingmake debug.
Log Files
Each make debug run writes logs to a per-session directory under work-tmp/debug/ and updates work-tmp/debug/latest/ to point at the most recent session.
Because latest/* is a symlink, it can move if multiple debug sessions are starting/stopping concurrently—prefer using the session directory path printed by make debug when you need stable log references.
You can find the exact session directory in the make debug startup output under the Log files section.
| File | Content |
|---|---|
work-tmp/debug/latest/backend.log | Python print() statements, Streamlit logs, errors |
work-tmp/debug/latest/frontend.log | Browser console.log(), React errors, Vite output |
Logs are cleared at the start of each session and persist after exit for post-mortem analysis.
Log size warning: Logs can grow large during extended debugging sessions. Instead of reading entire log files, use rg to search for specific patterns:
# Search for specific debug messages
rg "DEBUG:" work-tmp/debug/latest/backend.log
# Search for errors (case-insensitive)
rg -i "error|exception|traceback" work-tmp/debug/latest/backend.log
# Search with context (3 lines before/after)
rg -C 3 "my_function" work-tmp/debug/latest/backend.log
# Search frontend logs for specific component
rg "MyComponent" work-tmp/debug/latest/frontend.log
Use this directory for all debugging artifacts (scripts, screenshots, etc.) to keep them organized.
Adding Debug Output
Backend (Python):
print(f"DEBUG: session_state = {st.session_state}")
Frontend (TypeScript/React):
console.log("DEBUG: props =", props)
Frontend console.log() output appears in work-tmp/debug/latest/frontend.log (or the current session's frontend.log file).
Workflow
- Create or use a test script in
work-tmp/debug/(e.g.,work-tmp/debug/test_feature.py) - Run
make debug work-tmp/debug/test_feature.py - Verify startup: Check
work-tmp/debug/latest/backend.logforError/Exceptionandwork-tmp/debug/latest/frontend.logfor console errors to ensure both servers started correctly - Access the printed App URL in your browser (default
http://localhost:3001, but it may be3002+) - Verify script execution: Check
work-tmp/debug/latest/backend.logagain for any errors after the first app access - Monitor logs by inspecting
work-tmp/debug/latest/backend.logandwork-tmp/debug/latest/frontend.log - Edit code - changes apply automatically via hot-reload
- Check logs for debug output
Quick error check:
# Backend errors
rg -i "error|exception" work-tmp/debug/latest/backend.log
# Frontend console errors
rg -i "error" work-tmp/debug/latest/frontend.log
Temporary Playwright Scripts for Screenshots & Testing
For advanced debugging with screenshots or automated UI interaction.
Quick: Playwright CLI
For simple screenshots and interactions, use @playwright/cli (available in frontend devDependencies):
cd frontend
STREAMLIT_APP_URL=http://localhost:3001
yarn playwright-cli open "$STREAMLIT_APP_URL"
yarn playwright-cli screenshot --filename ../work-tmp/debug/screenshot.png --full-page
yarn playwright-cli close
See https://github.com/microsoft/playwright-cli for more commands (snapshot, click, fill, etc.).
Custom Scripts
For complex interactions, create temporary Playwright scripts in work-tmp/debug/:
# work-tmp/debug/debug_screenshot.py
"""Temporary Playwright script for debugging - run against make debug."""
import os
from playwright.sync_api import sync_playwright, expect
from e2e_playwright.shared.app_utils import get_text_input, click_button
from e2e_playwright.conftest import wait_for_app_loaded, wait_for_app_run
def main():
app_url = os.environ.get("STREAMLIT_APP_URL", "http://localhost:3001")
with sync_playwright() as p:
browser = p.chromium.launch(headless=True)
page = browser.new_page(viewport={"width": 1280, "height": 720})
# Connect to app started with `make debug`
page.goto(app_url)
wait_for_app_loaded(page)
# Interact with the app
text_input = get_text_input(page, "Name")
text_input.fill("Test User")
click_button(page, "Submit")
wait_for_app_run(page)
# Verify and screenshot
expect(page.get_by_text("Hello, Test User")).to_be_visible()
page.screenshot(path="work-tmp/debug/debug_screenshot.png", full_page=True)
print("Screenshot saved to work-tmp/debug/debug_screenshot.png")
browser.close()
if __name__ == "__main__":
main()
Running Temporary Scripts
Ensure make debug <app.py> is running first (start it in a background task if needed). If your make debug session is using a non-default port, set STREAMLIT_APP_URL accordingly, then run the Playwright script:
STREAMLIT_APP_URL=http://localhost:3001 \
PYTHONPATH=. uv run python work-tmp/debug/debug_screenshot.py
This uses the uv-managed environment with all dependencies (playwright, etc.) and makes e2e_playwright importable without path manipulation.
Available Utilities from e2e_playwright
Element Locators & Interactions (e2e_playwright.shared.app_utils):
Provides helpers like get_text_input(), get_button(), click_button(), get_checkbox(), etc.
Synchronization (e2e_playwright.conftest):
wait_for_app_loaded(page)- wait for initial loadwait_for_app_run(page)- wait for script execution after interactionwait_until(page, fn, timeout)- poll until condition is true
Playwright API Reference: https://playwright.dev/python/docs/api/class-playwright
Screenshot Best Practices
# Full page screenshot
page.screenshot(path="work-tmp/debug/full.png", full_page=True)
# Element screenshot
element = page.get_by_test_id("stDataFrame")
element.screenshot(path="work-tmp/debug/dataframe.png")
Troubleshooting
Port already in use / multiple sessions:
make debugwill automatically pick a free frontend port (typically in the3001-3100range) so multiple debug sessions can run simultaneously.- Frontend port
3000is reserved for manualmake frontend-devsessions. - If you have a hard requirement for a specific frontend port, you can pin it with
VITE_PORT=3002 make debug <app.py>(last resort).
Hot-reload not working:
- Backend: Only the app script is watched. Changes to
lib/streamlit/require restartingmake debug. - Frontend: Check
work-tmp/debug/latest/frontend.logfor Vite errors. TypeScript errors can break HMR.
Playwright script fails to connect:
- Verify
make debugis running and healthy - Check the printed App URL is accessible in the browser
- Ensure
wait_for_app_loaded(page)is called afterpage.goto()
Cleanup
After debugging is complete, remove temporary scripts and screenshots from work-tmp/debug/.
Related Skills
- understanding-streamlit-architecture skill: For deeper understanding of backend/frontend internals when debugging cross-layer issues
When not to use it
- →When debugging changes to the core Streamlit library
Prerequisites
Limitations
- →Changes to lib/streamlit require manual restart
- →Logs can grow large during extended sessions
How it compares
It provides a centralized debug environment with automated log management and Playwright integration, replacing manual server restarts and log tracking.
Compared to similar skills
debugging-streamlit side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| debugging-streamlit (this skill) | 7 | 5mo | Review | Intermediate |
| podcast-generation | 1 | 3mo | Review | Advanced |
| python-error-handling | 1 | 2mo | No flags | Intermediate |
| telegram-dev | 2 | 8mo | Review | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by streamlit
View all by streamlit →You might also like
podcast-generation
microsoft
Generate AI-powered podcast-style audio narratives using Azure OpenAI's GPT Realtime Mini model via WebSocket. Use when building text-to-speech features, audio narrative generation, podcast creation from content, or integrating with Azure OpenAI Realtime API for real audio output. Covers full-stack implementation from React frontend to Python FastAPI backend with WebSocket streaming.
python-error-handling
wshobson
Python error handling patterns including input validation, exception hierarchies, and partial failure handling. Use when implementing validation logic, designing exception strategies, handling batch processing failures, or building robust APIs.
telegram-dev
2025Emma
Telegram 生态开发全栈指南 - 涵盖 Bot API、Mini Apps (Web Apps)、MTProto 客户端开发。包括消息处理、支付、内联模式、Webhook、认证、存储、传感器 API 等完整开发资源。
1k-performance
OneKeyHQ
Performance optimization for React/React Native — re-renders, memoization, FlashList, memory leaks, and bundle size.
fullstack-guardian
Jeffallan
Use when implementing features across frontend and backend, building APIs with UI, or creating end-to-end data flows. Invoke for feature implementation, API development, UI building, cross-stack work.
javascript-typescript-typescript-scaffold
sickn33
You are a TypeScript project architecture expert specializing in scaffolding production-ready Node.js and frontend applications. Generate complete project structures with modern tooling (pnpm, Vite, N