> For the complete documentation index, see llms.txt.
Skip to main content

Check out Port for yourself ➜ 

Getting started with agentic initiatives

This guide walks you through building the pattern described in Agentic initiatives: one entity represents a fix effort against a failing scorecard rule, and Port fans a coding agent out across every service that rule currently fails.

By the end, a platform engineer will be able to approve a Draft fix effort and watch Port create one tracked run per affected service, launch a Cursor agent against each repository, and roll every result back up into a single progress view.

Or implement it in one shot with your coding assistantCursorClaudeGitHub Copilot

Connect Port MCP to your coding assistant, then copy the prompt below to implement this entire guide automatically against your Port account.

I want to set up a fleet-wide scorecard remediation pattern in Port.

Rules that apply to every workflow you create:
- Reference node results as .outputs["<node identifier>"]. A webhook node's response body is at .outputs["<node identifier>"].response.data, and the entity that fired an event trigger is at .outputs["trigger"].diff.after.
- Port ends an expression at the first closing double braces. Never write two closing braces next to each other inside {{ }}: put a space between them, or build nested objects by joining small objects with +.

Here is what I need you to do, step by step:

1. Create a blueprint with identifier "agentic_initiative", title "Agentic Initiative", icon "Automation":
- description (markdown): what this initiative fixes
- prompt (markdown): the instruction given to the coding agent for every target
- approval_policy (string, enum: auto-merge, owner-approval, pe-approval)
- status (string, enum: Draft, Running, Completed, Cancelled)
- target_blueprint (string): the blueprint identifier the targets belong to
- reference_context (array): supporting links or entity identifiers for the agent
- target_entities (array): JSON objects of {serviceIdentifier, serviceTitle, repoUrl}, populated before the run begins

2. Create a blueprint with identifier "run_target", title "Run Target", icon "Branch":
- target_blueprint, target_identifier, target_title (strings)
- target_url (string, url)
- status (string, enum: Pending, Running, PR Opened, Merged, Failed, Skipped)
- pr_url (string, url)
- pr_ci_status (string, enum: pending, passing, failing)
- error_message (string)
- agent_log_url (string, url)
- team_notified (boolean)
Add relations: service (target "service", not required, not many), pull_request (target "githubPullRequest", not required, not many), agentic_initiative (target "agentic_initiative", not required, not many).

3. Update the blueprint "agentic_initiative" to add aggregation properties targeting "run_target" entities, counting by status: total_targets (count all), targets_pending, targets_running, targets_pr_opened, targets_merged, targets_failed. Add them after "run_target" exists, because an aggregation property cannot target a blueprint that does not exist yet.

4. Create a Port workflow with identifier "agentic_initiative_executor", title "Kickoff initiative fixer agents":
- trigger (EVENT_TRIGGER): fires on ENTITY_UPDATED for agentic_initiative where status changed from Draft to Running.
- bulk_create_targets (WEBHOOK): POSTs to https://api.port.io/v1/blueprints/run_target/entities/bulk?upsert=true&create_missing_related_entities=false with the body {"entities": [...]}, building one target entity per object in the initiative's target_entities array with status Pending. Each entity has identifier "target-<serviceIdentifier>-<initiative identifier>", title serviceTitle, properties (target_blueprint "service", target_identifier, target_title, target_url set to repoUrl, status) and relations (service and agentic_initiative).
- start_targets (WEBHOOK): bulk-upserts the same targets with status Running so the per-target executor's Pending-to-Running trigger fires reliably.
Connections: trigger to bulk_create_targets to start_targets.

5. Install the Cursor cloud agents integration first, so its installation ID is ready for the cursor_agent node in the next step.

6. Create a Port workflow with identifier "agentic_target_executor", title "Execute task on a single service":
- manual_trigger (SELF_SERVE_TRIGGER) on the service blueprint, with a required "prompt" text input and the triggering service as context.
- fetch_service (WEBHOOK, GET): reads the service entity to get its title, repo URL, and identifier.
- create_run_target (UPSERT_ENTITY): creates a run_target entity with status Running for the manual path.
- trigger (EVENT_TRIGGER): fires on ENTITY_UPDATED for run_target where status changed from Pending to Running.
- fetch_agentic_initiative (WEBHOOK, GET): reads the parent initiative to get its prompt, when the run came from the fan-out path.
- cursor_agent (INTEGRATION_ACTION, Cursor cloud agents, create_agent): launches a Cursor cloud agent using the initiative prompt or the manual prompt, targeting the run target's repository. Use integrationProvider "cursor-cloud-agents". Set these integrationActionExecutionProperties: apiVersion "v0", reportCompletion true (so the node waits for the agent to finish), prompt (a plain string), repository (the repo URL), ref "main", and config.target with autoCreatePr true and branchName "port/agentic/<initiative id or manual>/<target identifier>". Build the prompt string as the initiative prompt (or the manual prompt), then a blank line, then "Target service: <title>" and "Repository: <url>" on two lines, then a blank line, then "Keep changes minimal and focused on the task. Open a pull request with your changes." The agent only opens a pull request when its prompt asks for one. When it finishes, the node returns status, workflowRunUrl and target.prUrl (the pull request it opened).
- check_success (CONDITION): has two outlets, success (.outputs["cursor_agent"].status == "FINISHED" and .outputs["cursor_agent"].target.prUrl != null) and failed (the opposite). Connect success to update_target_pr and failed to update_target_failed using sourceOutletIdentifier.
- update_target_pr (UPSERT_ENTITY, success branch): writes pr_url (.outputs["cursor_agent"].target.prUrl), status "PR Opened" and agent_log_url (.outputs["cursor_agent"].workflowRunUrl) back to the run_target.
- update_target_failed (UPSERT_ENTITY, failure branch): writes status "Failed" and an error_message ("Cursor agent did not finish with a pull request. Agent status: <status>") back to the run_target.
- link_pr_entity (AI, tools list_entities and upsert_entity): looks up the githubPullRequest entity whose link property equals .outputs["cursor_agent"].target.prUrl and sets the run_target's pull_request relation to it. If no entity matches yet, it does nothing.
Connections: both trigger paths converge on cursor_agent, which flows to check_success, which branches to update_target_pr (then link_pr_entity) or update_target_failed.

7. Create a Port workflow with identifier "begin_agentic_initiative", title "Begin Agentic Initiative":
- trigger (SELF_SERVE_TRIGGER): scoped to agentic_initiative entities where status equals Draft, with an ENTITY context on the initiative input so it appears in the bolt menu.
- start_initiative (UPSERT_ENTITY): sets the initiative status to Running.
Connection: trigger to start_initiative.

8. Create a Port workflow with identifier "sync_run_target_pr_merged", title "Sync PR merge status to run targets":
- trigger (EVENT_TRIGGER): fires on ENTITY_UPDATED for githubPullRequest where the mergedAt property changed from empty to set.
- find_run_target (WEBHOOK, POST search): POSTs to https://api.port.io/v1/blueprints/run_target/entities/search with the body {"query": {"combinator": "or", "rules": [...]}} (the query must be wrapped in "query"). The rules find run_target entities related to the merged pull request (operator relatedTo, blueprint githubPullRequest), falling back to a pr_url match on the pull request's link if the relation isn't set yet. The first match is at .outputs["find_run_target"].response.data.entities[0].identifier.
- mark_merged (UPSERT_ENTITY): sets the related run_target status to Merged.
Connections: trigger to find_run_target to mark_merged.

9. Make sure the GitHub integration's pull-request mapping includes states ["open", "closed"], so merged pull requests stay in the catalog and the step 8 workflow can run.

Use Port MCP to create each artifact. Confirm each step before moving to the next.

Prerequisites​

  • A Port account.
  • Port's GitHub integration installed, with service entities carrying a repo_url property (mirrored from the repository). The pull-request mapping must include states: ["open", "closed"], so merged pull requests stay in your catalog (see step 5).
  • A scorecard on the service blueprint with at least one rule a coding agent can actually fix, such as a missing CODEOWNERS file or a missing PR template. See Ensure production readiness if you don't have one yet.
  • The Cursor cloud agents integration is installed.
  • Your Cursor account is connected to GitHub with access to the repositories the agent will change. Without access, the launch fails with a Failed to verify existence of branch error.
Adapt to your stack

This guide uses Cursor as the coding agent and GitHub as the source of repositories. The pattern is the same with any coding agent that accepts a prompt and a repository, and any Git provider Port ingests.

Data model​

Two blueprints carry this pattern:

  • agentic_initiative - one entity per fix effort. Holds the prompt given to the agent, the approval policy, and the list of target services. Its aggregation properties (total_targets, targets_pending, targets_running, targets_pr_opened, targets_merged, targets_failed) count the related run_target entities by status, so the initiative always shows live progress without a separate dashboard build.
  • run_target - one entity per service touched by an initiative. Tracks that single service's run: status, the pull request it opened, CI result, and a link back to its parent initiative.

The counters on agentic_initiative target run_target entities, and Port does not save a counter that targets a blueprint that does not exist yet. We therefore create agentic_initiative without the counters, create run_target, and then add the counters to agentic_initiative.


agentic_initiative blueprint (click to expand)
{
"identifier": "agentic_initiative",
"title": "Agentic Initiative",
"icon": "Automation",
"schema": {
"properties": {
"description": {
"title": "Description",
"type": "string",
"format": "markdown"
},
"prompt": {
"title": "Agent Prompt",
"type": "string",
"format": "markdown"
},
"approval_policy": {
"title": "Approval Policy",
"type": "string",
"enum": ["auto-merge", "owner-approval", "pe-approval"],
"enumColors": {
"auto-merge": "yellow",
"owner-approval": "green",
"pe-approval": "blue"
}
},
"status": {
"title": "Status",
"type": "string",
"enum": ["Draft", "Running", "Completed", "Cancelled"],
"enumColors": {
"Draft": "lightGray",
"Running": "orange",
"Completed": "green",
"Cancelled": "red"
}
},
"target_blueprint": {
"title": "Target Blueprint",
"type": "string"
},
"reference_context": {
"title": "Reference Context",
"type": "array"
},
"target_entities": {
"title": "Target Entities",
"description": "JSON array of {serviceIdentifier, serviceTitle, repoUrl} objects, populated by Port AI before the run begins",
"type": "array"
}
},
"required": []
},
"relations": {}
}
run_target blueprint (click to expand)
{
"identifier": "run_target",
"title": "Run Target",
"icon": "Branch",
"schema": {
"properties": {
"target_blueprint": {
"title": "Target Blueprint",
"type": "string"
},
"target_identifier": {
"title": "Target Identifier",
"type": "string"
},
"target_title": {
"title": "Target Title",
"type": "string"
},
"target_url": {
"title": "Target URL",
"type": "string",
"format": "url"
},
"status": {
"title": "Status",
"type": "string",
"enum": ["Pending", "Running", "PR Opened", "Merged", "Failed", "Skipped"],
"enumColors": {
"Pending": "lightGray",
"Running": "orange",
"PR Opened": "blue",
"Merged": "green",
"Failed": "red",
"Skipped": "darkGray"
}
},
"pr_url": {
"title": "PR URL",
"type": "string",
"format": "url"
},
"pr_ci_status": {
"title": "CI Status",
"type": "string",
"enum": ["pending", "passing", "failing"],
"enumColors": {
"pending": "yellow",
"passing": "green",
"failing": "red"
}
},
"error_message": {
"title": "Error Message",
"type": "string"
},
"agent_log_url": {
"title": "Agent Log URL",
"type": "string",
"format": "url"
},
"team_notified": {
"title": "Team Notified",
"type": "boolean"
}
},
"required": []
},
"relations": {
"service": {
"title": "Service",
"target": "service",
"required": false,
"many": false
},
"pull_request": {
"title": "Pull Request",
"target": "githubPullRequest",
"required": false,
"many": false
},
"agentic_initiative": {
"title": "Agentic Initiative",
"target": "agentic_initiative",
"required": false,
"many": false
}
}
}
agentic_initiative progress counters (click to expand)

Add this block to the agentic_initiative blueprint after run_target exists. If the blueprint JSON already has an empty "aggregationProperties": {}, replace it with this block.

"aggregationProperties": {
"total_targets": {
"title": "Total Targets",
"type": "number",
"target": "run_target",
"calculationSpec": { "calculationBy": "entities", "func": "count" }
},
"targets_pending": {
"title": "Pending",
"type": "number",
"target": "run_target",
"query": {
"combinator": "and",
"rules": [{ "property": "status", "operator": "=", "value": "Pending" }]
},
"calculationSpec": { "calculationBy": "entities", "func": "count" }
},
"targets_running": {
"title": "Running",
"type": "number",
"target": "run_target",
"query": {
"combinator": "and",
"rules": [{ "property": "status", "operator": "=", "value": "Running" }]
},
"calculationSpec": { "calculationBy": "entities", "func": "count" }
},
"targets_pr_opened": {
"title": "PR Opened",
"type": "number",
"target": "run_target",
"query": {
"combinator": "and",
"rules": [{ "property": "status", "operator": "=", "value": "PR Opened" }]
},
"calculationSpec": { "calculationBy": "entities", "func": "count" }
},
"targets_merged": {
"title": "Merged",
"type": "number",
"target": "run_target",
"query": {
"combinator": "and",
"rules": [{ "property": "status", "operator": "=", "value": "Merged" }]
},
"calculationSpec": { "calculationBy": "entities", "func": "count" }
},
"targets_failed": {
"title": "Failed",
"type": "number",
"target": "run_target",
"query": {
"combinator": "and",
"rules": [{ "property": "status", "operator": "=", "value": "Failed" }]
},
"calculationSpec": { "calculationBy": "entities", "func": "count" }
}
}

Build it step by step​


Track progress​

The initiative's aggregation properties are the tracking view: total_targets, targets_pending, targets_running, targets_pr_opened, targets_merged, and targets_failed are counted from the related run_target entities, so the entity page for any initiative already shows where it stands. Port calculates the counts in the background, so a change on a target can take a while to show up on the initiative. The targets_merged count updates only after the workflow from step 5 propagates GitHub merge events onto linked run_target entities.

For a portfolio view across every initiative, add a table widget to a dashboard page scoped to the agentic_initiative blueprint, with the aggregation properties as columns. Add a second table scoped to run_target, grouped by status, when you want to see every pull request an initiative opened in one place.

What you built​

A platform engineer approves a Draft initiative. Port bulk-creates one run_target per service in its target list, starts each target, launches a Cursor agent against each repository, and writes the resulting pull request, CI status, and outcome back to that target. When pull requests merge, a follow-up workflow updates each linked target to Merged. The initiative entity rolls every target's status up into a single set of counts, so there's one place to check whether a fleet-wide fix is done, in progress, or stuck.

What's next​

  • Route approval by criticality - extend step 4 so approval_policy and the target service's tier decide whether a PR needs a human before merge, not just whether the initiative can start.
  • Populate target_entities automatically - connect Port AI to your scorecard's failing-rule results so a Draft initiative appears on its own, instead of being created by hand.
  • Notify the owning team - use the team_notified property on run_target to drive a Slack message when a PR opens on a service that team owns.
  • Add code review enrichment - the PR Enricher agent can surface catalog context on every PR this pattern opens.

For the full picture of where this pattern fits, see Agentic initiatives and the Idea to Production solution overview.