# How to write OpenShell policies

DevFeed: [How to write OpenShell policies](<https://devfeed.tech/articles/how-to-write-openshell-policies-127502.md>)

Original publisher: [Read original article](<https://nirmata.com/2026/11/11/how-to-write-openshell-policies/>)

Author: Ritesh Patel

Published: 2026-11-10T23:14:06.012746Z

Content type: tutorial

Language: en

Sources: [Nirmata](<https://devfeed.tech/sources/nirmata.md>)

Topics: [OpenShell](<https://devfeed.tech/topics/openshell.md>), [Access Control](<https://devfeed.tech/topics/access-control.md>), [policy-as-code](<https://devfeed.tech/topics/policy-as-code.md>), [Documentation](<https://devfeed.tech/topics/documentation.md>)

Tags: [ai](<https://devfeed.tech/tags/ai.md>), [ai-agents](<https://devfeed.tech/tags/ai-agents.md>), [filesystem](<https://devfeed.tech/tags/filesystem.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [kubernetes](<https://devfeed.tech/tags/kubernetes.md>), [kubernetes-security](<https://devfeed.tech/tags/kubernetes-security.md>), [live](<https://devfeed.tech/tags/live.md>), [network](<https://devfeed.tech/tags/network.md>), [openshell](<https://devfeed.tech/tags/openshell.md>), [policies](<https://devfeed.tech/tags/policies.md>), [policy](<https://devfeed.tech/tags/policy.md>), [policy-as-code](<https://devfeed.tech/tags/policy-as-code.md>), [rules](<https://devfeed.tech/tags/rules.md>), [sandbox](<https://devfeed.tech/tags/sandbox.md>), [verify](<https://devfeed.tech/tags/verify.md>), [write](<https://devfeed.tech/tags/write.md>), [yaml](<https://devfeed.tech/tags/yaml.md>)

## AI overview

OpenShell policies deny unlisted access and split settings by when they take effect: filesystem, Landlock, and process settings are fixed at sandbox startup, while network rules can be updated live. Write narrow network rules per binary and endpoint, naming the executable that opens the connection; rules combine every listed binary with every endpoint, and child processes inherit them. Network enforcement defaults to audit, which logs violations but allows requests; set enforce to block, and remember matching deny rules always take precedence. Landlock best_effort logs a high-severity finding and runs without filesystem rules if they cannot be enforced; hard_requirement prevents startup. After updates, check that the latest revision is Loaded and inspect the effective policy. Filesystem changes require recreating the sandbox, which stops processes and removes state.

## Source excerpt

Write an OpenShell sandbox policy in YAML: set filesystem and Landlock rules at startup, scope each network rule to one binary, then verify changes live.