prefer-context-authz

prefer-context-authz is a cursor rule for coding agents from atlassian/forge-skills. It costs 1,205 tokens per session, scanned A, original, Apache-2.0.

A coding rule for Forge functions that says information already supplied in a validated context object should be used there instead of being copied into the function’s input data.

In plain words
What is it for?
Use it when designing or reviewing Forge function and resolver arguments, especially for values such as the signed-in user’s account ID.
Why use it?
It avoids duplicating trusted information in an unvalidated payload and reduces the need for the app to validate it again.

Cursor rule

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/atlassian/forge-skills/prefer-context-authz
Clone the repo
git clone --depth 1 https://github.com/atlassian/forge-skills

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for prefer-context-authz

README.md
[![agentmods](https://agentmods.dev/badge/rules/atlassian/forge-skills/prefer-context-authz.svg)](https://agentmods.dev/rules/atlassian/forge-skills/prefer-context-authz)
Your own site
<a href="https://agentmods.dev/rules/atlassian/forge-skills/prefer-context-authz"><img src="https://agentmods.dev/badge/rules/atlassian/forge-skills/prefer-context-authz.svg" alt="Measured on agentmods" height="20"></a>
Per session 1,205 This file is loaded in full into every session.
When invoked 1,205 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.01205 $0.01205
Opus 5 $0.00602 $0.00602
Sonnet 5 $0.00241 $0.00241
Haiku 4.5 $0.00120 $0.00120

Measured 4d ago against content hash 1423a7fa4a52, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

prefer-context-authz scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/forge-security-review/assets/security-rules/forge-authn-authz/prefer-context-authz.mdc · 149 lines

How it starts

The opening of the file, as written. The whole thing — 149 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Context

  • This rule uses terms which may have more up-to-date explanations from the Forge MCP server
  • Forge functions may be distinguished from other JS functions by:
    • Being exported, and furthermore,
    • Being named under modules.functions.[].handler, as the last name in a .-separated chain
  • Forge functions receive two arguments: a module-specific payload, and an object containing contextual information for the function invocation. Call the latter one the "context object." See the signature described under "Forge Function Signature"
  • There are also forge resolver functions, which appear as the second argument of foo.define() calls, where foo is a variable constructed from a @forge/resolver Resolver object.
  • Forge resolver functions have a signature described under "Resolver Function Signature" in this rule, with a context object of type Context, and a payload named payload.
  • The context object is validated in full by the Forge platform. Some apps use an anti-pattern of passing information avilable in this object (commonly accountId) explicitly through the payload object instead. Since the latter is not validated, the app must validate it iself, but this may result in incorrect validation or even absent validation, and should be avoided.

Resolver Function Signature

type Context = {
  accountId?: string;
  accountType?: 'licensed' | 'unlicensed' | 'customer' | 'anonymous';
  cloudId?: string;
  workspaceId?: string;
  localId: string;
  installContext: string;
  environmentId: string;
  environmentType: string;
  extension: {
    config?: { [key: string]: any } // defined for macro extensions
    [key: string]: any;
  },
  installation?: {
    ari: {
      installationId: string;
      toString: () => string;
    },
    contexts: [
      {
        cloudId?: string,
        workspaceId?: string,
        toString: () => string
      }
    ]
  }
};

function define(
  functionKey: string,
  // IMPORTANT: this parameter receives the resolver dunction definition
  cb: (request: {
    payload: { [key in number | string]: any;},
    context: Context
  }) => Promise<{ [key: string]: any } | string | void> | { [key: string]: any } | string | void,
): this

Forge Function Signature

// The type of the context object
export type Context = {
  installContext: string;
  principal?: Principal;
  license?: License;
  installation?: Installation;
  workspaceId?: string;
}

export type Principal = {
  accountId: string;
}

export type License = {
  isActive: boolean;
  billingPeriod?: string | null;
  capabilitySet?: string | null;
  ccpEntitlementId?: string | null;
  ccpEntitlementSlug?: string | null;
  isEvaluation?: boolean | null;
  subscriptionEndDate?: string | null;
  supportEntitlementNumber?: string | null;
  trialEndDate?: string | null;
  type?: string | null;
};

export type Installation = {
  ari: InstallationAri;
  contexts: ContextAri[];
}

export type InstallationAri = {
    installationId: string;
    toString: () => string;
};

export type ContextAri = {
  cloudId?: string;
  workspaceId?: string;
  toString: () => string;
}

// IMPORTANT: This is the forge function
export const handler = (payload, context: Context) => {
  // Does something
}

Scope & Signals

  • Manifest location of interest: modules.functions.[].handler
  • Any resolver functions defined by .define() calls on a variable of type Resolver
  • Risk indicators:
    • The payload object contains fields that are identical or likely contain the same information as fields available in the context object. Note that the fields available in this object will depend on whether it is a resolver function or not

Detection Process

1. Extract all forge function `handler` keys from the manifest
2. Extract all `resolver` keys present, at any depth, under the `modules` key in the manifest
3. Treat all functions identified by (1) as forge functions, and all from (2) as resolver functions
4. Find the definition of each function in the source code
5. Check, as thoroughly as you can, how each of these functions use their payload objects. Look for field names or
   accesses which are likely to contain information similar to the context fields available for that type of function
   a. Pay closer attention to fields which are eventually passed to `asApp()` endpoint calls
6. If any likely such use is found, flag the function for review

Read the full file on GitHub · 149 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 149 lines · 1,205 tokens per session scan A 1423a7fa4a52

Subscribe to this mod's changes

prefer-context-authz is a cursor rule published in the GitHub repository atlassian/forge-skills (20 stars, last pushed 4d ago), licensed Apache-2.0. It adds 1,205 tokens to every session, about $0.0060 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.