Skip to content

Optimize AI agent setup#13800

Open
lukasmasuch wants to merge 23 commits intodevelopfrom
lukasmasuch/test-colocation-docs
Open

Optimize AI agent setup#13800
lukasmasuch wants to merge 23 commits intodevelopfrom
lukasmasuch/test-colocation-docs

Conversation

@lukasmasuch
Copy link
Collaborator

@lukasmasuch lukasmasuch commented Feb 3, 2026

Summary

Updates AI agent configurations and improves development tooling:

  • AI Agent Configs: Updated configurations for Claude Code, Cursor, Copilot, and Codex
  • Shared Skills: Codex now uses a symlink to .claude/skills/ for skill auto-discovery
  • PostToolUse Hook: Added async hook to auto-fix Python files after edits (ruff check + format)
  • Makefile Fix: Corrected ruff lint/format order in make check and make autofix (lint first, then format per ruff docs)
  • Documentation: Updated AGENTS.md files with development guidelines

Changes

AI Agent Configurations

  • .claude/settings.json: Command permissions and hooks configuration
  • .codex/skills.claude/skills/: Symlink for shared skill auto-discovery
  • .cursor/rules/: Updated Cursor rules
  • .github/copilot-instructions.md: Updated Copilot instructions

New Hook: post_edit_autofix.sh

Async PostToolUse hook that runs after Edit/Write operations on Python files:

  • Runs ruff check --fix then ruff format (correct order)
  • Respects ruff exclusions from pyproject.toml
  • Never fails on unfixable errors (just applies what it can)
  • Runs asynchronously so Claude continues working

Makefile Improvements

  • Fixed make check and make autofix to run ruff check --fix before ruff format
  • This follows ruff's recommended order: lint fixes can modify code, so formatting should run last

AGENTS.md Documentation Updates

  • lib/streamlit/AGENTS.md: Added theming and layout guidance - theming/layout calculations must be done in the frontend, not the Python backend; avoid using get_option("theme.primaryColor") in backend code
  • lib/tests/AGENTS.md: Added guidance on imports - imports should be at the top-level of test files unless there is a specific reason (e.g., integration requirements, circular imports)

Testing Plan

No additional tests needed. Configuration files are static and the hook has been manually tested.


Contribution License Agreement

By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.

- Added test file co-location conventions to Testing Strategy section in AGENTS.md
- Created .claude/settings.json with Claude Code permissions and plansDirectory setting
- Created .cursor/cli.json with Cursor CLI permissions
- Created .codex/config.toml with Codex skills configuration
- Updated gitignores to use whitelist pattern (allow specific files instead of blacklist)
- Generated GitHub Copilot and Cursor rule files from updated AGENTS.md

Co-Authored-By: Claude (claude-haiku-4-5) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings February 3, 2026 14:09
@lukasmasuch lukasmasuch requested a review from a team as a code owner February 3, 2026 14:09
@snyk-io
Copy link
Contributor

snyk-io bot commented Feb 3, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@lukasmasuch lukasmasuch added security-assessment-completed Security assessment has been completed for PR change:other PR contains other type of change impact:internal PR changes only affect internal code labels Feb 3, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 3, 2026

✅ PR preview is ready!

Name Link
📦 Wheel file https://core-previews.s3-us-west-2.amazonaws.com/pr-13800/streamlit-1.53.1-py3-none-any.whl
📦 @streamlit/component-v2-lib Download from artifacts
🕹️ Preview app pr-13800.streamlit.app (☁️ Deploy here if not accessible)

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds AI agent configuration files and enhances documentation by adding test file co-location conventions to help AI agents understand the project structure better.

Changes:

  • Added detailed test file location conventions to the Testing Strategy section across three documentation files (AGENTS.md, .github/copilot-instructions.md, .cursor/rules/overview.mdc)
  • Created configuration files for three AI coding assistants: Claude Code (.claude/settings.json), Cursor (.cursor/cli.json), and Codex (.codex/config.toml) with appropriate command permissions
  • Updated gitignore files for .claude/, .cursor/, and .codex/ directories to use whitelist patterns for better security

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
AGENTS.md Added test file co-location details to Testing Strategy section
.github/copilot-instructions.md Added test file co-location details to Testing Strategy section (identical to AGENTS.md)
.cursor/rules/overview.mdc Added test file co-location details to Testing Strategy section (identical to AGENTS.md)
.cursor/cli.json New file: Cursor CLI configuration with shell command permissions for make, uv, yarn, and gh
.cursor/.gitignore Updated to use whitelist pattern, ignoring all files by default and explicitly allowing specific tracked files
.codex/config.toml New file: Codex configuration registering two skills from .claude/skills/ directory
.codex/.gitignore New file: Whitelist pattern gitignore allowing only .gitignore and config.toml
.claude/settings.json Added plansDirectory and permissions configuration with allow/ask lists for bash commands
.claude/.gitignore Updated to use whitelist pattern, explicitly allowing specific files in hooks/ and skills/ directories

lukasmasuch and others added 10 commits February 3, 2026 15:17
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Run `ruff check --fix` before `ruff format` per ruff's recommended
order: linting fixes can modify code (e.g., removing unused imports),
so formatting should run last to ensure consistent style.

Co-Authored-By: Claude (claude-opus-4-5) <noreply@anthropic.com>
Replace explicit skill configurations in .codex/config.toml with a
symlink to .claude/skills/. Codex auto-discovers skills in .codex/skills/
and follows symlinks, so this provides a single source of truth.

Co-Authored-By: Claude (claude-opus-4-5) <noreply@anthropic.com>
The config file is no longer needed since skills are auto-discovered
via the symlink to .claude/skills/.

Co-Authored-By: Claude (claude-opus-4-5) <noreply@anthropic.com>
Adds an async hook that runs `ruff check --fix` and `ruff format` on
Python files after Edit/Write operations. The hook:
- Runs asynchronously so Claude continues working
- Only processes .py files
- Respects ruff's exclusions from pyproject.toml
- Never fails on unfixable lint errors (just applies what it can)

Co-Authored-By: Claude (claude-opus-4-5) <noreply@anthropic.com>
- Remove async flag to prevent race conditions with concurrent edits
- Reduce timeout to 5s (ruff is very fast)
- Add Cursor afterFileEdit hook using the same shared script
- Update script to handle both Claude and Cursor input formats

Co-Authored-By: Claude (claude-opus-4-5) <noreply@anthropic.com>
Move ruff-specific comments closer to the ruff commands and remove
outdated async reference.

Co-Authored-By: Claude (claude-opus-4-5) <noreply@anthropic.com>
Use ${CLAUDE_PROJECT_DIR:-$CURSOR_PROJECT_DIR} to support running the
hook in both Claude Code and Cursor environments.

Co-Authored-By: Claude (claude-opus-4-5) <noreply@anthropic.com>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a symlink to the .claude/skills folder

Comment on lines -457 to 539
echo "=== Python: format (ruff) ===" && \
uv run ruff format $$PY_FILES && \
echo "" && \
echo "=== Python: lint (ruff) ===" && \
uv run ruff check --fix $$PY_FILES && \
echo "" && \
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the recommended way in ruff is to first apply check fixes and then the formatting

Comment on lines +460 to +462
echo "=== Python: format (ruff) ===" && \
uv run ruff format $$PY_FILES && \
echo "" && \
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the recommended way in ruff is to first apply ruff check auto fixes and then the formatting.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ruff format and check is extremely fast, especially on single files. Therefore, I think its fine to always run this in auto-fix mode after every file write or edit

@lukasmasuch lukasmasuch changed the title Add AI agent configurations and test file co-location docs Optimize AI agent setup Feb 3, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 3, 2026

📉 Frontend coverage change detected

The frontend unit test (vitest) coverage has decreased by 0.0500%

  • Current PR: 86.3800% (13706 lines, 1866 missed)
  • Latest develop: 86.4300% (13706 lines, 1859 missed)

💡 Consider adding more unit tests to maintain or improve coverage.

📊 View detailed coverage comparison

lukasmasuch and others added 2 commits February 3, 2026 16:21
Document that theming and layout calculations should be done in the
frontend, not the Python backend. Using get_option("theme.primaryColor")
is unreliable since themes can be configured in multiple ways.

Co-Authored-By: Claude (claude-opus-4-5) <noreply@anthropic.com>
Move the theming and layout section from lib/AGENTS.md to the more
specific lib/streamlit/AGENTS.md, which contains guidelines specific
to Streamlit library development.

Co-Authored-By: Claude (claude-opus-4-5) <noreply@anthropic.com>
lukasmasuch and others added 5 commits February 3, 2026 16:27
Co-Authored-By: Claude (claude-opus-4-5) <noreply@anthropic.com>
Co-Authored-By: Claude (claude-opus-4-5) <noreply@anthropic.com>
Imports should be at the top-level of test files unless there is a
specific reason to place them inside test functions.

Co-Authored-By: Claude (claude-opus-4-5) <noreply@anthropic.com>
Co-Authored-By: Claude (claude-opus-4-5) <noreply@anthropic.com>
Exit silently if CLAUDE_PROJECT_DIR/CURSOR_PROJECT_DIR is unset or
doesn't exist, preventing the script from running in the wrong directory.

Co-Authored-By: Claude (claude-opus-4-5) <noreply@anthropic.com>
@lukasmasuch lukasmasuch added the ai-review If applied to PR or issue will run AI review workflow label Feb 3, 2026
@github-actions github-actions bot removed the ai-review If applied to PR or issue will run AI review workflow label Feb 3, 2026
lukasmasuch and others added 2 commits February 3, 2026 18:03
Co-Authored-By: Claude (claude-opus-4-5) <noreply@anthropic.com>
@streamlit streamlit deleted a comment from github-actions bot Feb 3, 2026
"Bash(uv sync *)",
"Bash(uv pip *)",
"Bash(yarn *)",
"Bash(gh *)",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: We should limit the gh subcommands to read-only commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:other PR contains other type of change impact:internal PR changes only affect internal code security-assessment-completed Security assessment has been completed for PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants