Agent skill
streamlit-1-use-caching-appropriately
Sub-skill of streamlit: 1. Use Caching Appropriately (+3).
Install this agent skill to your Project
npx add-skill https://github.com/vamseeachanta/workspace-hub/tree/main/.claude/skills/_archive/data/analysis/streamlit/1-use-caching-appropriately
SKILL.md
1. Use Caching Appropriately (+3)
1. Use Caching Appropriately
# GOOD: Cache data loading
@st.cache_data
def load_data():
return pd.read_csv("data.csv")
# GOOD: Cache resources (DB connections, models)
@st.cache_resource
def get_model():
return load_model("model.pkl")
# AVOID: Caching with unhashable arguments
# Use _arg prefix to skip hashing
@st.cache_data
def process_data(_db_connection, query):
return _db_connection.execute(query)
2. Organize Large Apps
# utils/data.py
def load_data():
pass
# utils/charts.py
def create_chart(df):
pass
# app.py
from utils.data import load_data
from utils.charts import create_chart
3. Handle State Carefully
# GOOD: Initialize state at the top
if "data" not in st.session_state:
st.session_state.data = None
# GOOD: Use callbacks for complex updates
def on_filter_change():
st.session_state.filtered_data = apply_filter(st.session_state.data)
st.selectbox("Filter", options, on_change=on_filter_change)
4. Optimize Performance
# Use containers for layout stability
placeholder = st.empty()
# Batch widget updates in forms
with st.form("filters"):
# Multiple widgets
st.form_submit_button()
# Use columns for responsive layout
cols = st.columns([1, 2, 1])
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
gsd-complete-milestone
Archive completed milestone and prepare for next version
gsd-reapply-patches
Reapply local modifications after a GSD update
gsd-verify-work
Validate built features through conversational UAT
gsd-thread
Manage persistent context threads for cross-session work
clinical-trial-protocol
Generate clinical trial protocols for medical devices or drugs through a modular, waypoint-based architecture with research-only and full protocol modes.
single-cell-rna-qc
Performs quality control on single-cell RNA-seq data (.h5ad or .h5 files) using scverse best practices with MAD-based filtering and comprehensive visualizations.
Didn't find tool you were looking for?