Manage AI Instructions with Port
In the age of AI coding agents (Claude, Copilot, Gemini, Cursor), teams need a single source of truth for how autonomous agents should contribute to repositories. Traditionally, these rules are stored manually in different locations based on the coding agent's specification - such as .cursor/rules
, .github/copilot-instructions
, or other agent-specific folders. However, managing these scattered files at scale is cumbersome and leads to inconsistency.
To deal with this challenge, you can adopt the AGENTS.md
structure as a unified standard for all AI coding instructions, regardless of the specific agent being used, and automate it with Port.
This guide demonstrates how to centralize these instructions inside your internal developer portal, and automatically sync them back into GitHub repositories whenever they are updated. This ensures consistency, visibility, and automation โ without developers needing to manually edit AGENTS.md
.

Common use casesโ
- Centralize AI guidelines by managing all AI agent instructions from a single location in Port
- Ensure consistency across repositories by automatically syncing updated instructions via pull requests
- Reduce manual overhead by eliminating the need for developers to manually update
AGENTS.md
files
Prerequisitesโ
This guide assumes the following:
- You have a Port account and have completed the onboarding process.
- GitHub integration is installed in your account.
- You have access to create and configure AI agents in Port.
- You have completed the setup in one of the following trigger coding agents guides:
- Trigger Claude Code from Port - for Claude Code integration
- Trigger GitHub Copilot from Port - for GitHub Copilot integration
- Trigger Gemini Assistant from Port - for Google Gemini integration
Set up data modelโ
We will enhance the GitHub repository blueprint to include AI instructions and configure the GitHub integration to sync these instructions automatically.
Update the repository blueprintโ
To track AI instructions, we need to add a property for managing AI agent contribution guidelines.
-
Go to the builder page of your portal.
-
Find and select your existing repository blueprint (e.g.,
githubRepository
). -
Click on
{...} Edit JSON
. -
Add the following property to the
properties
section:AI instructions property (click to expand)
"ai_instructions": {
"title": "AI Instructions",
"description": "Rules and contribution guidelines for AI coding agents",
"type": "string",
"format": "markdown"
} -
Click
Save
to update the blueprint.
Update GitHub integration mappingโ
Now we need to configure the GitHub integration to automatically sync the AI instructions between Port and GitHub repositories.
-
Go to the data sources page of your portal.
-
Find your GitHub integration and click on it.
-
Go to the
Mapping
tab. -
Update the mapping configuration to include the AI instructions property:
GitHub integration mapping configuration (click to expand)
deleteDependentEntities: false
createMissingRelatedEntities: true
enableMergeEntity: true
resources:
- kind: repository
selector:
query: true
port:
entity:
mappings:
identifier: .full_name
title: .name
blueprint: '"service"'
properties:
readme: file://README.md
ai_instructions: file://AGENTS.md
url: .html_url
defaultBranch: .default_branch -
Click
Save
to update the integration configuration.
The integration will look for the AGENTS.md
file at the root of each repository. Ensure your repositories follow this standardized file structure for consistent mapping across your organization.
Centralizing AI instructionsโ
The AGENTS.md pattern involves creating a centralized AGENTS.md
file at the root of your repository that serves as the single source of truth for all AI coding instructions. To make your AI coding agents reference this standardized file, you need to configure them to point to it:
- Cursor
- GitHub Copilot
- Claude Code
- Other AI Agents
Create a .cursor/rules
file in your repository with the following configuration:
---
description: General Guidelines
globs:
alwaysApply: true
---
@AGENTS.md
This configuration tells Cursor to always apply the guidelines from the AGENTS.md
file to all files in your repository.
In your repository settings or create a .github/copilot-instructions.md
file with:
Reference the `AGENTS.md` file for all coding guidelines and instructions.
For Claude Code, you can reference the AGENTS.md
file in your CLAUDE.md
:
Please follow the coding guidelines and instructions specified in the `AGENTS.md` file at the root of this repository.
For other AI coding agents, configure them to reference the AGENTS.md
file in their respective configuration files:
- Gemini CLI: Add reference in your
GEMINI.md
custom instructions file - Custom agents: Include instructions to read and follow the
AGENTS.md
file
The key is to ensure all agents point to the same centralized source of truth.
Configure AI agentโ
Before setting up the automation, we need to create an AI agent that will handle the actual file updates in GitHub repositories. Choose the configuration that matches your preferred AI coding agent:
- Claude Code
- GitHub Copilot
- Google Gemini
-
Go to the AI agents page of your portal.
-
Click on
+ AI Agent
. -
Click on the
{...} Edit JSON
button. -
Copy and paste the following JSON configuration:
AI Instructions Manager Claude agent configuration (click to expand)
{
"identifier": "ai_instructions_manager",
"title": "AI Instructions Manager",
"icon": "Details",
"team": [],
"properties": {
"description": "AI agent that manages the AGENTS.md file in repositories via Claude Code",
"status": "active",
"allowed_blueprints": [
"service"
],
"allowed_actions": [
"run_claude_code"
],
"prompt": "You are an AI agent responsible for keeping the AGENTS.md file up to date in GitHub repositories.\n\nWhen you invoke the `run_claude_code` action:\n1. Set `repo_name` to the target repository.\n2. Construct the `command` so it includes the full new AGENTS.md Markdown provided by Port, not just a placeholder reference. The command must:\n - Clearly instruct Claude to replace the contents of `AGENTS.md` at the root of the repository.\n - Include the full Markdown text from Port inside a fenced code block.\n - End with instructions to commit on a new branch and open a PR with:\n - Title: 'chore: sync AGENTS.md from Port'\n - Description: 'This PR updates AGENTS.md based on the latest instructions from Port.'\n\nExample `command` format:\n\n```\nPlease update the repository by creating or replacing the AGENTS.md file at the root with the following content:\n\n```markdown\n<the full Markdown instructions provided by Port go here>\n```\n\nCommit this change on a new branch and open a pull request titled: 'chore: sync AGENTS.md from Port' with description: 'This PR updates AGENTS.md based on the latest instructions from Port.'\n```\n\nAlways embed the actual Markdown content directly. Never leave it as a placeholder or a reference.",
"execution_mode": "Automatic"
},
"relations": {}
} -
Click
Create
to save the agent.
-
Go to the AI agents page of your portal.
-
Click on
+ AI Agent
. -
Click on the
{...} Edit JSON
button. -
Copy and paste the following JSON configuration:
AI Instructions Manager Copilot agent configuration (click to expand)
{
"identifier": "ai_instructions_manager",
"title": "AI Instructions Manager",
"icon": "Github",
"team": [],
"properties": {
"description": "AI agent that manages coding rules and instructions via GitHub Copilot",
"status": "active",
"allowed_blueprints": [
"service"
],
"allowed_actions": [
"create_github_issue"
],
"prompt": "You are an AI agent responsible for keeping the AGENTS.md file up to date in GitHub repositories.\n\nWhen you invoke the `create_github_issue` action:\n1. Set the `title` to: 'Update AGENTS.md with latest AI instructions from Port'.\n2. Always include the following labels: ['ai-instructions', 'auto_assign'].\n3. Set the `body` to include **explicit task instructions** for GitHub Copilot, followed by the new Markdown content. Use this template:\n\n---\n## Task for Copilot\nUpdate the `AGENTS.md` file at the root of the repository. Replace its contents entirely with the Markdown provided below. Commit the change on a new branch and open a pull request with:\n- Title: 'chore: sync AGENTS.md from Port'\n- Description: 'This PR updates AGENTS.md based on the latest instructions from Port.'\n\n## New AGENTS.md Content\nMARKDOWN START\n<the full Markdown provided from Port>\nMARKDOWN END\n---\n\nDo not ask for clarification. Always assume the Markdown from Port is final. The issue body above is the full instruction for Copilot.",
"execution_mode": "Automatic"
},
"relations": {}
} -
Click
Create
to save the agent.
-
Go to the AI agents page of your portal.
-
Click on
+ AI Agent
. -
Click on the
{...} Edit JSON
button. -
Copy and paste the following JSON configuration:
AI Instructions Manager Gemini agent configuration (click to expand)
{
"identifier": "ai_instructions_manager",
"title": "AI Instructions Manager",
"icon": "Code",
"team": [],
"properties": {
"description": "AI agent that manages the AGENTS.md file in repositories via Google Gemini",
"status": "active",
"allowed_blueprints": [
"service"
],
"allowed_actions": [
"trigger_gemini_assistant"
],
"prompt": "You are an AI agent responsible for keeping the AGENTS.md file up to date in GitHub repositories.\n\nWhen you invoke the `trigger_gemini_assistant` action:\n1. Set `repo_name` to the target repository.\n2. Construct the `prompt` so it includes the full new AGENTS.md Markdown provided by Port, not just a placeholder reference. The prompt must:\n - Clearly instruct Gemini to replace the contents of `AGENTS.md` at the root of the repository.\n - Include the full Markdown text from Port inside a fenced code block.\n - End with instructions to commit on a new branch and open a PR with:\n - Title: 'chore: sync AGENTS.md from Port'\n - Description: 'This PR updates AGENTS.md based on the latest instructions from Port.'\n\nExample `prompt` format:\n\n```\nPlease update the repository by creating or replacing the AGENTS.md file at the root with the following content:\n\n```markdown\n<the full Markdown instructions provided by Port go here>\n```\n\nCommit this change on a new branch and open a pull request titled: 'chore: sync AGENTS.md from Port' with description: 'This PR updates AGENTS.md based on the latest instructions from Port.'\n```\n\nAlways embed the actual Markdown content directly. Never leave it as a placeholder or a reference.",
"execution_mode": "Automatic"
},
"relations": {}
} -
Click
Create
to save the agent.
You can customize the agent's behavior by:
- Modifying the prompt to include additional instructions
- Adding more allowed blueprints or actions
- Adjusting the execution mode based on your security requirements
- Including team assignments for better governance
Set up automationโ
When ai_instructions
changes in Port, you want those updates to be reflected in GitHub. For this, configure an automation that triggers whenever the property changes, and forwards the updated Markdown to the AI agent that manages AGENTS.md
.
-
Go to the Automations page of your portal.
-
Click on
+ Automation
. -
Copy and paste the following JSON configuration:
Update AI Instructions automation (click to expand)
{
"identifier": "update_ai_instructions",
"title": "Update AI Instructions",
"description": "Automation to trigger the AI agent when the AI instructions changes",
"icon": "AI",
"trigger": {
"type": "automation",
"event": {
"type": "ENTITY_UPDATED",
"blueprintIdentifier": "service"
},
"condition": {
"type": "JQ",
"expressions": [
".diff.before.properties.ai_instructions != .diff.after.properties.ai_instructions"
],
"combinator": "and"
}
},
"invocationMethod": {
"type": "WEBHOOK",
"url": "https://api.getport.io/v1/agent/ai_instructions_manager/invoke",
"agent": false,
"synchronized": true,
"method": "POST",
"headers": {
"RUN_ID": "{{ .run.id }}",
"Content-Type": "application/json"
},
"body": {
"prompt": "Update the repository '{{ .event.context.entityIdentifier }}'.\n\nCreate or replace the file `AGENTS.md` at the root with the following exact content\nMARKDOWN START:\n\n{{ .event.diff.after.properties.ai_instructions }}\n\nMARKDOWN END.\nCommit this change on a new branch and open a pull request.",
"labels": {
"source": "AI Instructions Manager",
"entityIdentifier": "{{ .event.context.entityIdentifier }}"
}
}
},
"publish": true
} -
Click
Create
to save the automation.
Test the workflowโ
Now let us test the complete workflow to ensure everything works correctly.
Update AI instructions in Portโ
- Go to your software catalog page.
- Find a repository entity that has AI instructions defined and edit it's content.
Verify GitHub pull requestโ
- Check your GitHub repository for a new pull request.
- Review the changes to ensure the
AGENTS.md
file was updated correctly. - Merge the pull request to complete the sync.

Related guidesโ
- Enforce AI coding security standards - Set up comprehensive AI coding security rules
- Track AI-driven pull requests - Monitor AI agent contributions to your codebase