agents/skills/policy-creation/SKILL.md
This skill provides guidance for adding and testing new enterprise policies within the Chromium codebase.
Before you start writing the policy, make sure you have the information needed to completely write the policy YAML. Do not make assumptions.
chrome/VERSION file. Use
this for the supported_on field.You MUST confirm this information with the user before making sure change. You MUST ask the user for:
owners of the policy. It MUST have at least 2 entries, and
be a combination of:
file://components/policy/OWNERS.fuchsia is no longer a
supported platform.future_on (prototype) or supported_on
(ready for release).per_profile.dynamic_refresh.You MUST NOT proceed with writing the YAML file until you have gathered all this information.
You MAY additionally ask the user:
All policies must be defined in the Chromium codebase.
components/policy/resources/templates/policies.yaml.Each policy belongs to a group. Define groups with a .group.details.yaml
file indicating caption and description.
Create a PolicyName.yaml file (e.g., FooEnabled.yaml) under the
appropriate group directory in policy_definitions/.
Ensure version and feature flags (dynamic_refresh, supported_on) are set
correctly.
Enabled, Disabled, and Not Set.<ph> tags for products (e.g., <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph>).Histograms: Run
python3 tools/metrics/histograms/update_policies.py --yes to sync with
enums.xml.
FooEnabled instead of FooDisabled, even if the default is
true).Api instead
of API).Policies fall into 6 main types:
string-enum-list if multiple options can be
chosen concurrently.If multiple policies are closely related and must be applied together from a single source, define an atomic group.
policies.yaml.policy_atomic_groups.yaml file.Policy values map to internal browser preferences.
per_profile in your PolicyName.yaml.
chrome/browser/prefs/browser_prefs.cc.ios/chrome/browser/shared/model/prefs/browser_prefs.mm.Use kSimplePolicyMap in
chrome/browser/policy/configuration_policy_handler_list_factory.cc (or
ios/chrome/browser/policy/model/configuration_policy_handler_list_factory.mm
for iOS) for 1-to-1 mappings.
You MAY use an #if BUILDFLAG(...) guard based on target platforms.
If validation is needed, implement a custom
ConfigurationPolicyHandler.
If the policy affects the hardware or login screen:
components/policy/proto/chrome_device_policy.proto.chrome/browser/ash/policy/core/device_policy_decoder.{h,cc}.Policy preference mappings must be tested to ensure the policy translates to the correct setting.
components/policy/test/data/pref_mapping/PolicyName.json.PolicyTestCase objects.
json [ { "os": ["win", "linux", "mac", "android"], "simple_policy_pref_mapping_test": { "pref_name": "your.pref.path", "default_value": false, "values_to_test": [true, false] } } ]ios/chrome/test/data/policy/pref_mapping/<PolicyName>.json.win, linux, mac, chromeos,
android, fuchsia) requires at least one meaningful test case.simple_policy_pref_mapping_test: For simple 1-to-1 mappings.policy_pref_mapping_tests: For complex interactions between multiple
policies/prefs.can_be_recommended),
set it to true to test both mandatory and recommended values.reason_for_missing_test_case.