Harness AI Rules
Use Harness AI Rules to tailor AI output to enterprise standards before Harness resources are created or changed.
Harness AI Rules are reusable instructions that Harness AI uses as context before it creates, edits, or reviews Harness resources. You can use rules to encode pipeline standards, security controls, cost limits, code norms, and team workflows so AI output is aligned to team standards before users save AI-generated resources.
Harness recommends you start with a small set of Account or Project rules, review AI output with your team, and then expand by category.
What you will learn in this topic
By the end of this topic, you will be able to understand:
Before you begin
Before you create Harness AI Rules, ensure you have the following:
Harness AI access: Harness AI must be active for your account. For more information on enabling Harness AI, see Overview of Harness AI.
Policy context: Rules guide AI output before save. For more information on enforcing Open Policy Agent (OPA) policies after a resource is saved or run, see Harness Policy As Code overview.
Rule behavior
Harness AI applies active rules to the current chat, page, and resource context. For example, when you use Harness AI in Pipeline Studio, pipeline rules can require security scan stages, approval steps, rollback plans, or specific deploy strategies before Harness AI proposes pipeline YAML.
Rules help with these tasks:
AI output: Tailor chat answers, resource definitions, pipeline YAML, code, and setup advice to your standards.
Context-aware guidance: Apply relevant standards based on the current page, selected scope, and rule category.
Earlier governance: Guide AI-generated resources before users spend time manually editing output.
Rule scopes
Harness AI merges applicable rules from each scope. When multiple rules address the same requirement, the most narrowly scoped rule takes precedence. Project rules override Organization rules, and Organization rules override Account rules.
Account
Account admin
Security requirements, compliance controls, cloud standards, cost controls.
Organization
Organization admin
Team standards, deploy windows, approval workflows, environment rules.
Project
Project admin
Service rules, project integrations, monitor thresholds, deploy patterns.
Personal
Individual user
Personal defaults, notification choices, reusable shortcuts, chat preferences.
Rule override controls are part of upcoming rule management capabilities. For more information, see Manage rule access.
Rule categories
Categories help Harness AI choose the right rules for the current page, entity, and task. Common categories include:
Pipeline: Pipeline stages, deploy flow, approvals, rollback rules, timeouts, and health checks.
Builds: Test coverage, image rules, scan requirements, build cache, and build time limits.
Deployment: Deploy strategy, environment promotion, production controls, and release notes.
Infrastructure: Cloud provider, region, instance, Kubernetes, and Terraform requirements.
Cloud Cost Management: Budgets, alert thresholds, instance rules, and cost guardrails.
Security: Static application security testing (SAST), dependency scans, secret rules, license checks, and least privilege controls.
Code: Branch names, pull requests, commit messages, README files, and code comment standards.
Verification: Health checks, smoke tests, canary checks, load tests, and post-deploy checks.
Create a rule
Create a rule at the scope where the standard must apply so Harness AI picks it up as context. Each rule captures a name, a category, a status, and the rule content itself.
Open Harness AI from the Harness page where you want AI help.
Select the more options menu, then select Settings.
Select the Rules tab.
Select the Rule level for the scope where the rule must apply.
Click New rule.
Enter the rule name, category, status (
draftoractive), and Markdown content.Click Save.

Click to view full size image
Use the Rules tab to choose a scope and add a new rule.

The rule form captures rule content before Harness AI applies it.
Use AI to write rules
Harness AI can help you create rule content from a plain-language prompt. Use this when you want a complete rule set but do not want to start from a blank editor.
Open the rule editor.
Select Generate with AI.
Describe the standard you want. For example, enter
All production pipelines must include an approval step, a security scan stage, and rollback logic.Review the generated Markdown.
Edit the rule so it matches your exact control.
Save the rule as draft or active.
Use Enhance with AI to improve existing rule text. Harness AI can make the rule clearer, more precise, and easier to evaluate.
Manage rule access
Rules saved at a shared scope affect everyone who uses Harness AI in that scope, so decide who owns them before you roll them out broadly.
Until rule-specific RBAC is available, use your current Harness administrative controls and internal change process to decide who should manage shared rules.
Write effective rules
Use clear, specific rule text. Harness AI can evaluate direct requirements more reliably than broad preferences.
State the resource: Name the resource type, such as pipeline, build, service, environment, connector, code repo, or dashboard.
Use required terms: Use words such as
must,must not,require, andblock.Name the condition: State when the rule applies, such as production deploys or services with more than 1000 daily active users.
Set the result: State what must pass, fail, exist, or stay absent.
Avoid vague text: Replace phrases such as
secure enoughwith exact controls such aszero critical vulnerabilities.
Example rule set
Use the following examples as a starting point for Account or Project rules.
Next steps
Overview of Harness AI: Review available AI features.
Effective Prompting with Harness AI: Write prompts that produce better output.
Harness AI DevOps Agent: Create and update pipelines with AI.
Harness Policy As Code overview: Enforce resource and pipeline policy gates.
Last updated
Was this helpful?