Source: https://frameworkrecipes.dev/shiny/

# Shiny: preserve requirements through advanced agent edits

Work through R examples of real application boundaries: Check Shiny session authorization inside the write observer; Remove Shiny’s session-owned temporary files on session end. Each recipe includes implementation code, integration prerequisites, failure-path tests to add, a Perch rule, and the captured broken/fixed source checks.

[Download the Shiny rule pack ZIP](https://reporules.fyi/shiny/rule-pack.zip) · [Inspect the YAML rules](https://reporules.fyi/shiny/rules.yaml)

R

## [Check Shiny session authorization inside the write observer](https://frameworkrecipes.dev/shiny/session-scoped-mutation/)

A hidden button is not permission enforcement. A Shiny observer can be triggered by a client input, so the write boundary must check the session’s verified permission and carry its tenant/user scope into the persistence adapter.

Broken edit flagged · corrected edit passes

R

## [Remove Shiny’s session-owned temporary files on session end](https://frameworkrecipes.dev/shiny/session-temp-cleanup/)

Session reports can contain private data and consume disk after the browser disconnects. Give each session its own directory and register cleanup with that session’s owner. A shared fixed path permits one session to overwrite or delete another’s report.

Broken edit flagged · corrected edit passes

## Use a correction as a saved requirement

Choose the failure you need to prevent, add the scoped rule to your repository, and check both the broken and corrected implementation. Ask your agent to inspect the finding, repair the code and recheck the same rule. Keep framework tests beside the model check.

Perch keeps the requirement beside the code. Reuse the named check during the agent’s next edit and in CI, with cached answers free on unchanged requests.

[Official Shiny documentation](https://shiny.posit.co/r/getstarted/) · [All language and framework recipes](https://frameworkrecipes.dev/)

**Framework Recipes**

Implementation, failure path, check.

Published by Perch · © 2026 Verglas LLC. Framework Recipes is a Perch publication.

Perch’s MIT license covers the CLI; hosted model analysis is a paid service. Relevant source is sent to the configured model service.

[Perch CLI MIT license](https://github.com/lakeday-org/perch/blob/main/LICENSE) · [Article text](https://frameworkrecipes.dev/shiny/index.md) · [Resource index](https://frameworkrecipes.dev/llms.txt)
