streamlit-development
БесплатноЗапускает вложенные скриптыНе проверенDeveloping, testing, and deploying Streamlit data applications on Snowflake. Use this skill when you're building interactive data apps, setting up local…
Об этом скилле
Streamlit Development
Build interactive data applications using Streamlit, test them locally, and deploy to Snowflake's native Streamlit environment.
Quick Start
Execution Modes:
- Local Development - PyPI packages, full environment
- Snowflake Deployment - Snowflake Anaconda packages, managed environment
Connection Pattern
Critical: Support both local development and Snowflake deployment:
import streamlit as st
from snowflake.snowpark.context import get_active_session
from snowflake.snowpark import Session
@st.cache_resource
def get_snowpark_session():
try:
return get_active_session() # Snowflake
except:
return Session.builder.config('connection_name', 'default').create() # Local
For connection setup, see the snowflake-connections skill for:
- Creating
~/.snowflake/connections.toml - Authentication methods (SSO, key pair, username/password)
- Multiple environment configurations
- Environment variable overrides
Local Development
Setup
# Install dependencies (pin Streamlit version to match Snowflake)
uv pip install --system -r requirements.txt
# Example requirements.txt
streamlit==1.46.0 # Must match Snowflake version
snowflake-snowpark-python
pandas
Run Locally
streamlit run app.py
# Or with environment overrides (see snowflake-connections skill)
SNOWFLAKE_DATABASE=MY_DB streamlit run app.py
Testing
Unit/Integration Tests
pytest streamlit_app/tests/ -v
Browser Testing
Use Playwright MCP for interactive testing:
- Verify pages load without errors
- Test forms and navigation
- Check responsive design
See TESTING_GUIDE.md for patterns.
Deployment
Option 1: Snowflake CLI (Recommended)
snow streamlit deploy --replace -c default
Option 2: Schemachange
Include Streamlit deployment in migration scripts.
Key Patterns
- Separate data access from UI logic
- Cache Snowpark sessions
- Use forms for multi-field input
- Handle errors gracefully
- Limit column nesting (max 2 levels)
See TROUBLESHOOTING.md for common issues.
Related Skills
Complementary Testing:
playwright-mcpskill - Automate browser testing for Streamlit apps
Use playwright-mcp for visual testing, form validation, responsive design testing, and accessibility checks of your Streamlit applications.
Code Organization Best Practices
1. Separate Data Access from UI
✅ DO: Modular data access
# utils/data_loader.py
class DataQueries:
def __init__(self, session):
self.session = session
def get_sales(self, start_date, end_date):
return self.session.sql(f"""
SELECT * FROM sales
WHERE date BETWEEN '{start_date}' AND '{end_date}'
""").to_pandas()
# app.py
from utils.data_loader import DataQueries
session = get_snowpark_session()
queries = DataQueries(session)
df = queries.get_sales('2024-01-01', '2024-12-31')
st.dataframe(df)
❌ DON'T: Mix SQL with UI code
2. Cache Snowpark Session
Always cache your session to avoid reconnection overhead:
@st.cache_resource
def get_snowpark_session():
"""Get or create Snowpark session (cached)"""
try:
return get_active_session() # When running in Snowflake
except:
from snowflake.snowpark import Session
return Session.builder.config('connection_name', 'default').create()
3. Use Forms for Multi-Field Input
✅ DO: Group inputs in forms
with st.form("customer_form"):
name = st.text_input("Name")
email = st.text_input("Email")
phone = st.text_input("Phone")
if st.form_submit_button("Save"):
save_customer(name, email, phone)
st.success("Customer saved!")
❌ DON'T: Trigger rerun on every input (causes rerun on every keystroke)
4. Handle Errors Gracefully
Provide helpful feedback:
try:
save_customer(name, email)
st.success("✅ Customer saved successfully!")
except ValueError as e:
st.error(f"❌ Invalid input: {e}")
st.info("💡 Tip: Check that email format is correct")
except Exception as e:
st.error(f"❌ Unexpected error: {e}")
st.info("💡 Please contact support if this persists")
5. Limit Column Nesting (Max 2 Levels)
✅ DO: 2 levels maximum
col1, col2 = st.columns(2)
with col1:
label_col, input_col = st.columns([1, 3])
with label_col:
st.markdown("**Name:**")
with input_col:
name = st.text_input("Name", label_visibility="collapsed")
❌ DON'T: 3+ levels of nested columns (causes Streamlit errors)
Performance Optimization
Cache Data Queries
@st.cache_data(ttl=600) # Cache for 10 minutes
def load_sales_data(start_date, end_date):
return session.sql(f"""
SELECT * FROM sales
WHERE date BETWEEN '{start_date}' AND '{end_date}'
""").to_pandas()
Use Session State
#
Установить streamlit-development в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл streamlit-development?
Developing, testing, and deploying Streamlit data applications on Snowflake. Use this skill when you're building interactive data apps, setting up local development environments, testing with pytest or Playwright, or deploying apps to Snowflake using Streamlit in Snowflake.
Как установить скилл streamlit-development?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл streamlit-development запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic