OpenClaude Safety Strictness Levels: A Complete Guide to Strict, Balanced, and Permissive Modes

OpenClaude provides three configurable safety strictness levels—strict, balanced, and permissive—that control how aggressively the assistant filters content, with the setting managed via the OPENCLAUDE_SAFETY_LEVEL environment variable and accessed through functions in the permission utilities.

The Gitlawb/openclaude repository implements a tiered safety system allowing developers to tune content moderation aggressiveness. Understanding these OpenClaude safety strictness levels is essential for deploying the assistant in environments ranging from high-security enterprise settings to open research contexts.

Understanding the Three OpenClaude Safety Strictness Levels

The system defines three distinct modes represented by the SafetyLevel type in src/utils/permissions/safetyLevel.ts. Each level determines when and how the assistant blocks potentially problematic content.

Strict Level

The strict level represents the most protective configuration. Content that might be unsafe, disallowed, or could lead to policy violations is blocked as early as possible. This setting is intended for environments requiring the highest degree of content safety, such as production systems serving sensitive user bases.

Balanced Level

Balanced serves as the default strictness level in OpenClaude CLI deployments. It provides middle-ground filtering where obvious safety concerns are blocked while maintaining flexibility for legitimate queries. This prevents unnecessary rejections while still enforcing core safety policies.

Permissive Level

The permissive level applies fewer safety checks, allowing the model to respond to borderline prompts that stricter settings would reject. Use this mode only when you trust downstream moderation systems or require maximum openness for specific research scenarios.

Configuring Safety Levels in Your Application

According to the Gitlawb/openclaude source code, safety strictness is controlled through environment variables and utility functions. The primary mechanism is the OPENCLAUDE_SAFETY_LEVEL environment variable, which the system reads through specialized getter functions.

Reading the Current Safety Level

The getSafetyLevel() function in src/utils/permissions/safetyLevel.ts retrieves the active configuration, defaulting to balanced when no environment variable is set. This function caches the result for performance, returning the same value until explicitly cleared.

Changing Safety Levels at Runtime

To modify the safety strictness after initialization, update the OPENCLAUDE_SAFETY_LEVEL environment variable and call resetSafetyLevelCache(). This clears the internal cache and forces the system to re-read the configuration:

// Import the safety-level API
import { getSafetyLevel, resetSafetyLevelCache } from '@/utils/permissions/safetyLevel.js';

// Show the current strictness level (defaults to "balanced")
console.log('Current safety level:', getSafetyLevel()); // → "balanced"

// Switch to a stricter mode for a sensitive operation
process.env.OPENCLAUDE_SAFETY_LEVEL = 'strict';
resetSafetyLevelCache(); // clear the cached value
console.log('After change:', getSafetyLevel()); // → "strict"

// Later you can revert to the permissive level
process.env.OPENCLAUDE_SAFETY_LEVEL = 'permissive';
resetSafetyLevelCache();
console.log('Now permissive:', getSafetyLevel()); // → "permissive"

Implementation Details and Testing Utilities

The safety level architecture includes dedicated testing infrastructure to ensure reliable behavior across different configurations.

Core Implementation File

The file src/utils/permissions/safetyLevel.ts defines the SafetyLevel type and exports both getSafetyLevel() and resetSafetyLevelCache(). This module handles environment variable parsing and maintains the internal cache state that optimizes repeated lookups.

Unit Testing and Cache Reset

The test suite in src/utils/permissions/safetyLevel.test.ts validates the default behavior and cache clearing functionality. For integration testing, src/test/safetyLevelTestHelpers.ts provides utilities that reset the safety level between test cases, ensuring isolation and preventing configuration leakage across tests.

Summary

  • OpenClaude implements three safety strictness levels—strict, balanced, and permissive—to control content filtering aggressiveness.
  • The active level is stored in the OPENCLAUDE_SAFETY_LEVEL environment variable and defaults to balanced when unspecified.
  • Use getSafetyLevel() from src/utils/permissions/safetyLevel.ts to read the current configuration, and resetSafetyLevelCache() to force re-reading after changes.
  • Strict mode blocks content earliest for maximum safety, while permissive mode allows borderline queries for specialized use cases.
  • The testing framework includes dedicated helpers in src/test/safetyLevelTestHelpers.ts to manage state between tests.

Frequently Asked Questions

What is the default OpenClaude safety strictness level?

The default level is balanced, as defined in the source code. When the OPENCLAUDE_SAFETY_LEVEL environment variable is not set, the getSafetyLevel() function automatically returns "balanced", providing moderate content filtering suitable for most CLI applications.

How do I change the safety level in a running OpenClaude application?

Update the process.env.OPENCLAUDE_SAFETY_LEVEL variable to your desired value ("strict", "balanced", or "permissive"), then invoke resetSafetyLevelCache() to clear the internal cache. The next call to getSafetyLevel() will return the updated value from the environment.

Where is the SafetyLevel type defined in the OpenClaude repository?

The SafetyLevel type and associated functions are defined in src/utils/permissions/safetyLevel.ts within the Gitlawb/openclaude repository. This file also contains the default value constant and the caching logic used by getSafetyLevel().

Why does OpenClaude cache the safety level value?

The system caches the safety level to avoid repeatedly reading environment variables during high-frequency permission checks. The resetSafetyLevelCache() function exists specifically to invalidate this cache during testing or when runtime configuration changes require immediate effect.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →