Skip to content
Back to skills

Ab Assignment

ASecurity

Wire Metica's AB Assignment package (com.abassignment.unity) into a Unity project that has both a MeticaSDK route and the game's own AppLovin MAX route, or check a wiring that already exists. Sets the route from ABAssignment.Current.RunMetica when ads start, gives MeticaSDK and MAX the same user id, adds ReportRemoteConfig, ReportAdsInit and TagPlacement on both routes, then runs the validator's ab_assignment rules. Use when the user asks to add, set up, integrate, wire, check or review AB As...

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 30, 2026
ai-agentsgoc#shellbashexpressgitapi

Works with

  • cli
  • api

Security analysis

A100/100

Scanned December 2, 2026

npx -y skills add meticalabs/metica-sdk-agents --skill ab-assignment --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Ab Assignment?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Ab Assignment
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/meticalabs-ab-assignment/badge)](https://www.skillsdirectory.com/skills/meticalabs-ab-assignment)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: ab-assignment
description: Wire Metica's AB Assignment package (com.abassignment.unity) into a Unity project that has both a MeticaSDK route and the game's own AppLovin MAX route, or check a wiring that already exists. Sets the route from ABAssignment.Current.RunMetica when ads start, gives MeticaSDK and MAX the same user id, adds ReportRemoteConfig, ReportAdsInit and TagPlacement on both routes, then runs the validator's ab_assignment rules. Use when the user asks to add, set up, integrate, wire, check or review AB Assignment, the Metica vs Baseline split, the assignment library, or ABAssignment code.
---

# Metica AB Assignment

> This is a skill, not a sub-agent, because the work is a conversation: the user confirms the plan, answers the user id question, and often comes back with a device log. It runs on any integration, whether the integrator generated it or the studio wrote it by hand.

AB Assignment splits players into a Metica group (ads through MeticaSDK) and a Baseline group (ads through the game's own MAX code).
This skill connects the package to a project that already has both routes, and checks the result.

It has two modes:

- **Wire** (the default): discover, plan, edit after one approval, then check.
- **Check only**: when the user asks to check, validate or review. It runs Steps 1, 2, 6 and 7 and writes nothing.

## Resolve the plugin root

Defensive - `$CLAUDE_PLUGIN_ROOT` is sometimes unset in plugin bash environments, so locate the resolver across known install locations and self-verify the root.

```bash
PLUGIN_DIR=""
for cand in "${CLAUDE_PLUGIN_ROOT:-}" "${METICA_SDK_AGENTS_DIR:-}" \
            "$(ls -d "$HOME"/.claude/plugins/cache/*/metica-sdk-agents/* 2>/dev/null | sort -V 2>/dev/null | tail -1)" \
            "$HOME"/.claude/plugins/cache/*/metica-sdk-agents/* \
            "$HOME/.claude/plugins/marketplaces/metica-sdk-agents" \
            "$HOME/.claude/plugins/metica-sdk-agents" \
            "$HOME/.metica-sdk-agents" "$HOME/dev/metica-sdk-agents"; do
    [ -n "$cand" ] && [ -f "$cand/scripts/resolve-plugin-dir.sh" ] || continue
    PLUGIN_DIR="$(bash "$cand/scripts/resolve-plugin-dir.sh" 2>/dev/null)" && [ -n "$PLUGIN_DIR" ] && break
done
[ -n "$PLUGIN_DIR" ] || { echo "Could not locate metica-sdk-agents plugin root. Set METICA_SDK_AGENTS_DIR to the plugin path and retry." >&2; exit 1; }
```

Run it with `echo "PLUGIN_DIR=$PLUGIN_DIR"` at the end. Every command runs in a fresh shell, so write that absolute path, and the absolute `PROJECT` path from Step 1, in place of `$PLUGIN_DIR` and `$PROJECT` in every later command.

## Read the rules first

Read `$PLUGIN_DIR/references/ab-assignment.md` completely before anything else.
It is the single source of truth: the package rules, the user id rule, and every code shape this skill writes.
Take each line you add from its "Code shapes" section.

## Step 1 - Preconditions

1. **Project.** Find the Unity project root: the nearest directory, from `$(pwd)` up to four parents, that holds `ProjectSettings/ProjectSettings.asset`, unless the user passed `PROJECT`. Set `PROJECT` to its absolute path and say which project you found.
2. **Package.** Follow "Detecting the package" in the reference.
   - Absent: stop. Point the user to the install step in the package README (<https://github.com/meticalabs/ab-assignment-unity#1-install>).
   - Legacy id: stop. Tell the user to move to `com.abassignment.unity` first.
3. **Scan.** Run the scan and keep its output; Steps 2 to 5 work from it, and Step 6 runs it again so the validator sees the code as it is then:

   ```bash
   SCAN="$(mktemp "${TMPDIR:-/tmp}/ab-assignment-scan.XXXXXX")" && bash "$PLUGIN_DIR/scripts/ab-assignment-scan.sh" "$PROJECT" > "$SCAN" && echo "AB_SCAN=$SCAN" && cat "$SCAN"
   ```

   Keep `PLUGIN_DIR` as an absolute path: Step 6 passes it to the validator, together with the `AB_SCAN` path of the scan that Step 6 runs.
   Each hit has `file`, `line`, `owner`, `definition` and `kinds`. An `owner` of `game` is game code; `wrapper:<package>` is a **studio wrapper**: the studio's own ad package, which is part of the integration. Read a wrapper, never edit it, and find the game-code line that calls into it (grep `Assets/` for the wrapper method's name).
   A hit with `definition: true` is a method declaration, not a call.
   A hit with owner `sample` (under `Assets/Samples/`) counts only when game code calls into it.
   A package in `Packages/manifest.json` that is neither under `Packages/` nor in `Library/PackageCache/` (a fresh clone) is not on disk, so a studio wrapper in it is invisible to the scan. List those packages, tell the user to open the project in Unity once so they are fetched, and stop; never conclude that a route or call is missing.
4. **Both routes are in the code.**
   - **Metica route:** a `metica_init` hit that passes a `MeticaMediationInfo` (an init with a `null` one is analytics-only).
   - **MAX route:** a `max_init` hit.

   When both routes have a hit, continue, and say where each init is (game code, or wrapper `<package name>` reached from `<game file:line>`).
   When a route has no hit:
   - Check-only mode: record it as a finding and continue. The validator reports it.
   - Wire mode, no Metica route: stop and tell the user to run the `unity-integrator` agent first. With the package installed, the integrator keeps the game's MAX path.
   - Wire mode, no MAX route: stop, because the Baseline group has nothing to run. The user restores it (the `pre-metica-integration` git tag holds the original) or re-runs the integrator with `MAX_MODE=switchable`.
5. **Mode.** Read `mode` in the scan.
   With `client-managed` the game owns the split: run check only, and say why.
   With `unknown`, answer the scan's question about the `SetAssignmentMode` argument by reading the code, and continue in the mode it sets.

## Step 2 - Discover

Read every scan hit in its file, with the method around it, and record each finding with its `file:line`.
The scan's `verdicts` are already decided ("Scan verdicts" in the reference): record each one as a FAIL finding.
In wire mode, Step 3 plans the fix for each one, and the report takes its scan verdicts from the scan that Step 6 runs after the edits.
Answer every `for_the_model` question from the code: a call-order question with the reference's decision rule, a banner question by reading each listed site, and a sample-code question by running a grep on `Assets/` for a game-code call into the listed sample method.
The scan does not list Remote Config or consent code: for those, run `grep -rnE --include='*.cs' 'FetchAsync|ActivateAsync|SetDefaultsAsync|FetchAndActivate|Consent' "$PROJECT/Assets"` and read the hits.

Record:

- **Route decision.** Either a `MeticaAdService.UseMetica` switch (the integrator's switchable output) and the place the bootstrap reads it, or a branch the studio wrote between the MeticaSDK init and the MAX init, with the value that drives it.
- **Ads start.** The method that starts ads, and what calls it. Note when it runs at app start as rule 3 of the reference defines it: synchronously in startup code (`Awake` / `Start` of the first scene, a `RuntimeInitializeOnLoadMethod`) with no consent flow before it. A chain that reaches ads start only after the consent flow completes is not app start.
- **Package calls already present.** `ABAssignment.Initialize`, `ReportRemoteConfig`, `Current` / `TryGetCurrent`, `ReportAdsInit`, `TagPlacement`, `ReportCustomId`.
- **Remote Config.** Where the game fetches and activates Remote Config, and whether its in-app defaults (`SetDefaultsAsync`) include `metica_assignment`.
- **User ids.** Every `MeticaInitConfig` with its third argument (a game can have two: an analytics-only `MeticaSdk.InitializeAnalytics` at startup and the ads init later, and the first init's id wins), and every `MaxSdk.SetUserId` call. When a wrapper builds the `MeticaInitConfig` from a parameter, record the argument the game passes at its call site. For the MAX route, write down yes or no: does a `MaxSdk.SetUserId` run before `MaxSdk.InitializeSdk()` on every path? With the scan's `ab_assignment_user_id_known` verdict the answer is no; otherwise answer the scan's question with the reference's decision rule for call order. A call only in `OnSdkInitializedEvent`, after the init, or on the Metica route is a no. The Metica route needs no `MaxSdk.SetUserId`: MeticaSDK sets the MAX user id itself.
- **Placements.** Every show call with its placement argument or the lack of one, and every banner / MRec create with its placement setter or the lack of one, on both routes.
- **Assembly definition.** The `.asmdef` that owns the files you will edit, if there is one.
- **The game's own GDPR prompt**, if it has one. This is for the report only.

The scan skips `//` comment lines; Read each hit to confirm it is live code, not a string or a block comment.

## Step 3 - Plan and one approval

Show the findings, then the edits you will make, each as file plus kind of change. Prefer plan mode when it is available.
Raise these before asking for approval:

- Ads start at app start (rule 3 of the reference): the group would be decided before Remote Config answers. Moving the ads start is the user's decision.
- No Remote Config fetch in the game: the package cannot learn the value. The package ships a ready fetch in its "Basic integration" sample.
- Another value already decides the route (a remote flag, another A/B test): the package has to be the only thing that decides it. The package's own `SetDebugOverride` is a development tool and does not count.
- `MaxSdk.SetUserId` already called with an id that is not the one on the Metica route.
- A `null` or empty MeticaSDK user id, or a MAX route with no `MaxSdk.SetUserId`: the package does not know the id the ad stack uses.

Ask the user id question, unless every `MeticaInitConfig` and the MAX route already use `ABAssignment.UserId`:

```
MeticaSDK and MAX must get the same user id, and the package must know it.
  1) ABAssignment.UserId in both SDKs (the package's own id, nothing else to wire)
  2) your own player id in both SDKs, reported with ABAssignment.ReportCustomId
     (type the C# expression)
  3) ABAssignment.UserId in both SDKs, and your own player id reported with
     ABAssignment.ReportCustomId as a link (type the C# expression)
```

Never replace a game's own id with `ABAssignment.UserId` by default. Pick the default from what the game has:

- **The game has its own player id.** Ask whether it exists before the first MeticaSDK init of every launch (an analytics-only init included), a fresh install included, and whether it ever changes. When it always exists and never changes, option 2 is the default; otherwise option 3 is.
- **The game already gives MeticaSDK its own id, in a build that has shipped.** Keeping that id (option 2 with the same expression) is the default. Say in the plan that any other id makes every existing player a new Metica user with a new trial / holdout draw ("The user id rule"), so a switch needs agreement with Metica.
- **The game has no id of its own.** Option 1 is the default. Ask whether a build with MeticaSDK has shipped, since the code cannot tell. If it has and the game passes `null` or an empty id today, MeticaSDK uses an id it generated on the device, which no option keeps in automatic mode: state that any id is a switch, and ask with no default.
- **Package version.** Offer options 2 and 3 only when the installed package source defines `ReportCustomId` (grep the package folder or the copied sources; the version string is not reliable, since tag v2.2.0 still says 2.1.0). Otherwise say that the own-id case needs the upgrade first.

Take one approval for the whole plan. Write nothing before it.

## Step 4 - Snapshot

When the project is a git repository with a clean tree, tag the current commit before the first edit:

```bash
git -C "$PROJECT" tag -f pre-ab-assignment
```

With uncommitted changes or no repository, tell the user and wait for a go-ahead.

## Step 5 - Apply the edits

Make each edit with the shapes from the reference, skip what Step 2 found already in place, and keep the game logic around every call you touch (frequency caps, cooldowns, availability guards).
Every edit goes in game code under `Assets/`. When a studio wrapper starts an SDK, put the reference's lines at the game-code call into the wrapper, as the reference's "Code shapes" show.

1. **App start.** Add the `ABAssignment.Initialize` startup method to the class that owns the MeticaSDK init (the generated `MeticaAdService` when there is one). Give it the same app id and API key that `MeticaInitConfig` gets: reuse the constants when the code has them, and repeat the same literals when it does not (the integrator's generated `MeticaAdService` holds literals). Mind the argument order, which the reference spells out.
2. **Remote Config.** Add the three `ReportRemoteConfig` calls to the game's existing fetch, ahead of its other handlers.
3. **Ads start.** Make the package's decision drive the route, read once where ads start.
   - With a `MeticaAdService.UseMetica` switch: assign `ABAssignment.Current.RunMetica` to it immediately before the bootstrap reads it.
   - With a branch the studio wrote: read `ABAssignment.Current.RunMetica` once into a local at the ads start and branch on that.
4. **Metica route.** Pass the chosen user id to every `MeticaInitConfig`, the analytics-only one included: the game's own id with option 2, otherwise `ABAssignment.UserId` (or the `UserId` of an `AssignmentResult` the code already holds: it is the same id). Report `AdsInitStage.Started` just before the MeticaSDK init, and the outcome with the SmartFloors group and forced-holdout flag once init returns.
5. **MAX route.** Call `MaxSdk.SetUserId` with the same id before `MaxSdk.InitializeSdk()`. Report `AdsInitStage.Started` before the init and the outcome from the game's `OnSdkInitializedEvent` handler, back on the main thread.
6. **Placements.** Pass every placement through `ABAssignment.TagPlacement` on both routes, and pass `ABAssignment.TagPlacement(null)` to a show call that has no placement argument. Set the tagged banner / MRec placement right after each create, re-create included, and add a setter with `ABAssignment.TagPlacement(null)` where the game sets none. Never keep a tagged string in PlayerPrefs or a save file.
7. **Own id.** With option 2 or 3, add the `ReportCustomId(<GameId>)` shape: next to the ads-start read for option 2, and on the main thread where the game's id first exists for option 3.

When an edited file compiles into an assembly definition, that asmdef's `references` need `AB.Assignment`, and `MaxSdk.Scripts` when the edit adds a `MaxSdk` call: add each one the list does not hold yet.
Code in `Assembly-CSharp` needs nothing.

## Step 6 - Check

Run the Step 1 scan command again, in both modes.
Its output is the **current scan**: in wire mode the edits changed the code and its line numbers, so the Step 1 scan is out of date.
From here on, use only the current scan's verdicts and its `AB_SCAN` path.
Then run the `unity-validator` agent on the project in a fresh subagent context. Its prompt is exactly these three lines, with absolute paths:

```
PROJECT=<project path>
PLUGIN_DIR=<plugin path>
AB_SCAN=<AB_SCAN path of the current scan>
```

A marketplace install names it `metica-sdk-agents:unity-validator`; in Codex it is the `metica_unity_validator` custom agent.
Run it in the foreground and wait for its JSON: never start it in the background, and never end your turn or write the report before the JSON is back.
When it returns no JSON block, run it once more.
When the second run also returns none, write the report with "validator: no result" in place of the validator rows: report every verdict of the current scan as FAIL, and every other `ab_assignment_*` rule as `ADVISORY <rule id>: not checked, the validator returned no result`.

From its JSON:

- Report every `ab_assignment_*` row with its level, location and detail.
- **The scan wins.** For each verdict of the current scan whose rule the validator did not FAIL, report that rule as FAIL with the scan's reason, sites and fix, and say the validator rated it otherwise.
  The one exception is the scan exit ("Scan verdicts" in the reference): when the validator's row for that rule is ADVISORY and its `unresolved` cites the `file:line` the scan exit asks for, report the row as ADVISORY.
  Never report a scan verdict as PASS.
- Every fix goes in game code. When a row's detail puts the fix inside a wrapper, `Assets/MeticaSdk/`, `Assets/MaxSdk/` or a package, restate it at the game-code call that reaches that line, using the reference's "Code shapes".
  The one exception is the wrapper-owner form in Step 7.
- For an `ab_assignment_*` FAIL in a file this run edited, fix it, run the scan again (its output is now the current scan) and run the validator once more with the new `AB_SCAN`.
  Stop after two rounds.
- Report any other FAIL in one line each. Those rules belong to the MeticaSDK integration itself, and this skill does not change them.

## Step 7 - Report

Copy this template and fill it in. Keep every heading and the table header as written, in this order. Write `none` under a heading that has nothing, and leave out only the headings marked "wire mode". Every finding line starts with its level and rule id.

````markdown
## Project

`<project path>`, <wire | check only>, <automatic | client-managed> mode, package <version>.

## Routes

| Route | SDK init | Reached from game code | User id to MeticaSDK | User id to MAX, before its init | Package knows the id |
|---|---|---|---|---|---|
| Metica (`RunMetica` true) | <init call, file:line, or wrapper `<package>` file:line> | <game file:line> | <id expression> | set by MeticaSDK | <yes / no> |
| MAX (`RunMetica` false) | <init call, file:line, or wrapper `<package>` file:line> | <game file:line> | not started | <id expression and file:line, or none> | <yes / no> |

## Findings

- FAIL `<rule id>` at `<file:line>`: <what is wrong and why it matters>.
  Fix at `<game file:line>`:
  ```csharp
  <the lines to add, from "Code shapes">
  ```
- ADVISORY `<rule id>` at `<file:line>`: <what could not be verified and what to check>.
- PASS `<rule id>`: <one line>.

## Other validator FAILs

- `<rule id>` at `<file:line>`: <one line>.
- Warning: <each validator `warnings` entry, as given>.

## Wired (wire mode)

- `<file:line>`: <edit>. Both routes now use `<user id expression>`.

## Left to the user

- Publish the `metica_assignment` Remote Config parameter: JSON, no conditions, no in-app default (<https://github.com/meticalabs/ab-assignment-unity#2-set-up-the-firebase-parameter>).
- Stop any other test that decides Metica on or off.
- <Only when Step 2 found the game's own GDPR prompt and no `ABAssignment.SetConsentStatus` call: call it from that prompt. No validator rule covers this.>
- The kill switch is the same parameter with `"enabled": false`.

## Check on a device

- `adb logcat -s Unity | grep ABAssignment` in a development build shows `Events go to Metica ingestion at ... for app <app id>.`, `Group metica, route metica, ...` or `Group baseline, route own, ...`, `Sent <n> event(s) to Metica (HTTP 202, ...)`, and ad placements that start with `metica|` or `baseline|`.
- On Android, on both routes, `adb logcat -s AppLovinSdk | grep setUserIdentifier` shows `[AppLovinSdkSettings] setUserIdentifier(userIdentifier=<id>)` with the chosen id and no later line that overwrites it. The validator cannot see a write made by a compiled plugin, and this check has no iOS equivalent here.

## Undo (wire mode)

`git reset --hard pre-ab-assignment` (print it as a hint; never run it).
````

List every `ab_assignment_*` rule under Findings, PASS rows included, so the user sees all seven.
With "validator: no result", the seven are the current scan's verdicts as FAIL and the remaining rules as the ADVISORY line from Step 6.
Under every FAIL, write the `Fix at <game file>:<line>:` line with a real line number (the line the new code goes before) and then a `csharp` block with the exact lines to add, the user id expression included. A fix described only in words, or a fix line with no line number, is incomplete.
Only when no game-code line can hold the fix, write `Fix in <package> (its owner changes it):` instead, with the code for the wrapper.
The reference names the two cases: a studio wrapper that starts MAX from its own `RuntimeInitializeOnLoadMethod`, and a studio wrapper that creates the banner / MRec and takes no placement.

## Hard rules

- Never edit files under `Assets/MaxSdk/`, `Assets/MeticaSdk/`, `Packages/` or `Library/PackageCache/`. Studio wrappers there are read-only.
- Never run the validator in the background.
- Never add a read of `ABAssignment.Current`, a `TagPlacement` call or a `ReportAdsInit` call that runs at app start.
- Never write a Remote Config fetch the game does not have, and never add an in-app default for `metica_assignment`.
- One approval before the first write. Check-only mode writes nothing.
- Never print API keys or SDK keys.
- Every FAIL in the report has a `Fix at <game file>:<line>:` line (or `Fix in <package> (its owner changes it):` when no game-code line can hold the fix) and a code block.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.