Agent skill

Using Streamlit Session State

by iusztinpaul in iusztinpaul/designing-real-world-ai-agents-workshop

Using st.sessionstate to manage state across Streamlit reruns.

Apache-2.0Auto-check passedAgent Workflows

Install Using Streamlit Session State

skills CLI
$ npx skills add iusztinpaul/designing-real-world-ai-agents-workshop --skill using-streamlit-session-state -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install iusztinpaul/designing-real-world-ai-agents-workshop using-streamlit-session-state --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/iusztinpaul/designing-real-world-ai-agents-workshop.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/developing-with-streamlit/skills/using-streamlit-session-state .claude/skills/using-streamlit-session-state && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
using-streamlit-session-state
GitHub stars
513
Token cost
~1k tokens
SKILL.md length
216 words
Files
1
Skills in repo
23
Repo updated
First seen
Licence
Apache-2.0

At a glance

Using st.sessionstate to manage state across Streamlit reruns.

  • Persisting data
  • SKILL.md covers Basic usage, Widget-state association, Callbacks and Initialization patterns, plus 4 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md
  • Handling widget state

What it does

Using Streamlit Session State is an agent skill from iusztinpaul/designing-real-world-ai-agents-workshop. Using st.sessionstate to manage state across Streamlit reruns. Use when persisting data, handling widget state, implementing callbacks, or debugging state issues. Covers initialization patterns, widget-state association, and common gotchas.

Its SKILL.md is about 1k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Agent Workflows, covering Session handoff. It works with Streamlit. The repository describes itself as: Hands-on workshop: Build a multi-agent AI system from scratch — Deep Research Agent + Writing Workflow served as MCP servers. Includes code, slides, and video. The licence is Apache-2.0.

When your agent uses it

  • Persisting data
  • Handling widget state
  • Implementing callbacks
  • Debugging state issues

Example prompts

  • “/using-streamlit-session-state”

Requirements

  • Python 3

What it can do on your machine

Read from SKILL.md and the folder at commit ea4f6e9. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are python).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • docs.streamlit.io

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Using Streamlit Session State loads about 1k tokens when it runs. Until then it costs about 68 tokens; SKILL.md has 216 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~68
When it runs · the whole SKILL.md, loaded when a task matches
~1k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from iusztinpaul/designing-real-world-ai-agents-workshop at commit ea4f6e9, republished under its Apache-2.0 licence (© iusztinpaul). 216 words, ~1,001 tokens.

Download SKILL.mdSave it as .claude/skills/using-streamlit-session-state/SKILL.md (or your agent's skills folder).
name
using-streamlit-session-state
description
Using st.session_state to manage state across Streamlit reruns. Use when persisting data, handling widget state, implementing callbacks, or debugging state issues. Covers initialization patterns, widget-state association, and common gotchas.
license
Apache-2.0

Using Streamlit session state

Streamlit reruns scripts top-to-bottom on every interaction. Without session state, variables reset each time. Use st.session_state to persist values across reruns.

Basic usage

Session state is a dictionary-like object supporting attribute and bracket notation:

python
# Initialize with setdefault (preferred)
st.session_state.setdefault("count", 0)

# Alternative: check before setting
if "count" not in st.session_state:
    st.session_state.count = 0

# Read
current = st.session_state.count

# Update
st.session_state.count += 1
st.session_state["count"] = 5  # Bracket notation also works

# Delete
del st.session_state.count

Accessing uninitialized keys raises KeyError. Use st.session_state.get("key", default) for safe access.

Widget-state association

Every widget with a key parameter automatically syncs to session state:

python
name = st.text_input("Name", key="user_name")
# st.session_state.user_name contains the same value as `name`

Callbacks

Callbacks execute before the script reruns, allowing immediate state changes. Use on_change or on_click with optional args and kwargs:

python
def increment(amount):
    st.session_state.count += amount

st.button("Add 5", on_click=increment, args=(5,))

Access a widget's value in its own callback via st.session_state.key, not the return variable.

Initialization patterns

Initialize all state at the top of your app for clarity:

python
st.session_state.setdefault("user", None)
st.session_state.setdefault("page", "home")
st.session_state.setdefault("filters", {})

Multipage state

Widgets are NOT stateful across pages. Their values reset when navigating between pages.

Sharing state

Use session state variables (not widget keys) to share data:

python
# Page 1: Store value
st.session_state.selected_user = st.selectbox("User", users)

# Page 2: Read stored value
if "selected_user" in st.session_state:
    st.write(f"Selected: {st.session_state.selected_user}")
Shared widgets pattern

Put common widgets in the entrypoint file (before nav.run()):

python
# app.py (entrypoint)
with st.sidebar:
    st.session_state.theme = st.selectbox("Theme", ["Light", "Dark"])

nav = st.navigation(pages)
nav.run()

Common mistakes

Module-level mutable state
python
# BAD: In imported modules, this is shared across ALL users
# utils.py
cache = {}  # Persists across reruns AND users!

# GOOD: Use session state for per-user data
st.session_state.setdefault("cache", {})
Modifying state after widget creation

Cannot assign to a widget's state after the widget has rendered:

python
st.slider("Value", key="my_slider")
st.session_state.my_slider = 50  # Raises StreamlitAPIException!
Mixing value parameter and session state

Don't set both—it causes warnings:

python
# BAD: Conflicting sources
st.session_state.setdefault("name", "Alice")
st.text_input("Name", value="Bob", key="name")  # Warning!

# GOOD: Use one or the other
st.session_state.setdefault("name", "Alice")
st.text_input("Name", key="name")

Session characteristics

  • Per-user, per-tab: Each browser tab has its own session
  • Temporary: Lost when tab closes or server restarts
  • Not suitable for persistence: Use databases for permanent storage

References

© iusztinpaul, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .agents/skills/developing-with-streamlit/skills/using-streamlit-session-state of iusztinpaul/designing-real-world-ai-agents-workshop.

Open the folder on GitHubat commit ea4f6e9

Compare with similar skills

Using Streamlit Session State next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Using Streamlit Session State compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Using Streamlit Session State this skilliusztinpaul/designing-real-world-ai-agents-workshop513—~1kAutomated safety check: PassApache-2.0
Writing Streamlit AppsPostHog/posthog40k—~1.5kAutomated safety check: PassCustom licence
Developing With Streamlitstreamlit/agent-skills223—~412Automated safety check: PassApache-2.0
Orca CLIstablyai/orca87k2 repos~593Automated safety check: PassMIT
Coding Agent Session Findercode-yeongyu/oh-my-openagent70k1 repos~2.8kAutomated safety check: PassCustom licence
Beads Task Memorygastownhall/beads28k—~1.2kAutomated safety check: PassMIT

Similar skills

  • Writing Streamlit Apps

    PostHog/posthog

    Official

    Write Streamlit app source code that runs well in a PostHog sandbox — the posthogapps.query() bridge for reading PostHog data, the packages baked into the sandbox image, caching and session state…

    40k GitHub stars~1.5k tokensUpdated today
    DevelopmentAuto-check passed
  • Developing With Streamlit

    streamlit/agent-skills

    A skill your agent uses for ALL Streamlit tasks: creating, editing, debugging, beautifying, styling, theming, optimizing, or deploying Streamlit apps.

    223 GitHub stars~412 tokensUpdated 2 mo ago
    Frontend & DesignAuto-check passed
  • Orca CLI

    stablyai/orca

    Operate Orca-managed worktrees, folder contexts, terminals, repos, automations, artifacts, skill sharing, worktree comments, and Orca's embedded browser…

    87k GitHub starsUsed in 2 repos~593 tokens
    Agent WorkflowsAuto-check passed
  • Coding Agent Session Finder

    code-yeongyu/oh-my-openagent

    Finds, reads and reconstructs past coding-agent sessions across Codex, Claude, OpenCode, Senpi and many other local agent logs.

    70k GitHub starsUsed in 1 repo~2.8k tokens
    Agent WorkflowsAuto-check passed
  • Beads Task Memory

    gastownhall/beads

    Tracks multi-session work with dependencies in the bd issue tracker so the agent can find ready tasks and recover its context after conversation compaction.

    28k GitHub stars~1.2k tokensUpdated today
    Agent WorkflowsAuto-check passed
  • Searches past Claude Code, Codex and Cursor sessions and summarizes what was worked on, tried or decided, using extraction scripts instead of reading raw logs.

    24k GitHub stars~3.1k tokensUpdated today
    Agent WorkflowsAuto-check passed

More from iusztinpaul/designing-real-world-ai-agents-workshop

All 23 skills in this repo
  • Building Streamlit Custom Components V2

    iusztinpaul/designing-real-world-ai-agents-workshop

    Builds bidirectional Streamlit Custom Components v2 (CCv2) using st.components.v2.component.

    513 GitHub stars~2.8k tokensUpdated 4 mo ago
    Auto-check passed
  • Building Streamlit Chat UI

    iusztinpaul/designing-real-world-ai-agents-workshop

    Building chat interfaces in Streamlit. An agent skill from iusztinpaul/designing-real-world-ai-agents-workshop.

    513 GitHub stars~1.4k tokensUpdated 4 mo ago
    Auto-check passed
  • Building Streamlit Dashboards

    iusztinpaul/designing-real-world-ai-agents-workshop

    Building dashboards in Streamlit. An agent skill from iusztinpaul/designing-real-world-ai-agents-workshop.

    513 GitHub stars~1.1k tokensUpdated 4 mo ago
    Auto-check passed
  • Building Streamlit Multipage Apps

    iusztinpaul/designing-real-world-ai-agents-workshop

    Building multi-page Streamlit apps. An agent skill from iusztinpaul/designing-real-world-ai-agents-workshop.

    513 GitHub stars~1.6k tokensUpdated 4 mo ago
    Auto-check passed
  • Choosing Streamlit Selection Widgets

    iusztinpaul/designing-real-world-ai-agents-workshop

    Choosing the right Streamlit selection widget. An agent skill from iusztinpaul/designing-real-world-ai-agents-workshop.

    513 GitHub stars~1.1k tokensUpdated 4 mo ago
    Auto-check passed
  • Connecting Streamlit To Snowflake

    iusztinpaul/designing-real-world-ai-agents-workshop

    Connecting Streamlit apps to Snowflake. An agent skill from iusztinpaul/designing-real-world-ai-agents-workshop.

    513 GitHub stars~1.3k tokensUpdated 4 mo ago
    Auto-check passed

Works with

Categories

Questions about Using Streamlit Session State

What does Using Streamlit Session State do?

Using st.sessionstate to manage state across Streamlit reruns. Using Streamlit Session State is an agent skill from iusztinpaul/designing-real-world-ai-agents-workshop.sessionstate to manage state across Streamlit reruns.

When should I use Using Streamlit Session State?

Using Streamlit Session State fits situations like: persisting data; handling widget state; implementing callbacks; debugging state issues.

How do I install Using Streamlit Session State in Claude Code?

Run `npx skills add iusztinpaul/designing-real-world-ai-agents-workshop --skill using-streamlit-session-state -a claude-code`. Or copy the skill folder (.agents/skills/developing-with-streamlit/skills/using-streamlit-session-state in iusztinpaul/designing-real-world-ai-agents-workshop) into .claude/skills/using-streamlit-session-state in your project. Claude Code loads it when a task matches its description.

How do I install Using Streamlit Session State in Codex?

Run `npx skills add iusztinpaul/designing-real-world-ai-agents-workshop --skill using-streamlit-session-state -a codex`. Or copy the skill folder (.agents/skills/developing-with-streamlit/skills/using-streamlit-session-state in iusztinpaul/designing-real-world-ai-agents-workshop) into .agents/skills/using-streamlit-session-state in your project. Codex loads it when a task matches its description.

Can I use Using Streamlit Session State in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add iusztinpaul/designing-real-world-ai-agents-workshop --skill using-streamlit-session-state -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/using-streamlit-session-state, .gemini/skills/using-streamlit-session-state, .github/skills/using-streamlit-session-state and .opencode/skills/using-streamlit-session-state in your project.

What does Using Streamlit Session State need to run?

SKILL.md names no scripts, command-line tools or credentials: Using Streamlit Session State is instructions for the agent only. Our summary lists: Python 3.

Does Using Streamlit Session State access the network?

SKILL.md names 1 domain. As links in the text: docs.streamlit.io. This is read from the text; nothing was executed.

Is Using Streamlit Session State safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Using Streamlit Session State use?

Using Streamlit Session State is published under the Apache-2.0 licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Using Streamlit Session State use?

About 1k tokens (SKILL.md is roughly 4k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Using Streamlit Session State?

Skills that share tags, products or a category with Using Streamlit Session State: Writing Streamlit Apps (PostHog/posthog, 40k stars), Developing With Streamlit (streamlit/agent-skills, 223 stars), Orca CLI (stablyai/orca, 87k stars) and Coding Agent Session Finder (code-yeongyu/oh-my-openagent, 70k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Using Streamlit Session State?

iusztinpaul (a GitHub user) maintains it in iusztinpaul/designing-real-world-ai-agents-workshop, which has 513 GitHub stars. The repository holds 23 skills in this directory. The repository was last updated on June 3, 2026.

Source: iusztinpaul/designing-real-world-ai-agents-workshop on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.