Skip to content

t1k:unity:optimize:project-auditor

FieldValue
Moduleoptimize
Version2.35.6
Effortmedium
Tools—

Keywords: audio-import, mobile-perf, optimize, player-settings, project-auditor, projectauditor, texture-aniso, urp-hdr

/t1k:unity:optimize:project-auditor

Imports a Unity Project Auditor report (.projectauditor), filters it to a fixed set of high-confidence optimizations across two categories (ProjectSetting, AssetIssue), shows a dry-run, and — after one confirmation — applies the fixes to the live Unity Editor via a temporary Editor script compiled and triggered through t1k unity.

Apply mechanism (important): All apply logic runs through a temp Editor script + menu item: write Assets/Editor/ProjectAuditorApply.cs with [MenuItem] methods → t1k unity recompile compiles it → t1k unity menu 'Tools/Project Auditor/Apply Optimizations' triggers it → delete the script afterward. (One multi-statement t1k unity eval --file would also work; the menu path keeps the script reviewable on disk and is the tested shape.)

Scope is intentionally fixed. Only the 10 descriptors below. Code, Shaders, Build, and Summary categories are out of scope (code/shader fixes need human judgment; most code lives in read-only submodules in this template).

See also. For a static, Editor-closed asset audit — per-platform import policy, registered import Presets, URP/QualitySettings, duplicate content, shipping-vs-editor separation — see t1k:unity:optimize:assets. This skill consumes a .projectauditor report you already have.

A path to a .projectauditor report file. If the user did not supply one, ask for it (or offer to use the newest *.projectauditor in the repo root). The skill never runs its own audit — the user generates the report from the Project Auditor window (Window → Analysis → Project Auditor → Create a new report → save).

descriptorIdFix
PAS0033Audio Speaker Mode → Mono
PAS1010URP HDR → off on the flagged URP asset(s)
PAS0034Player: Use incremental GC → Enable
PAS0008Player: Optimize Mesh Data → Enable
PAS0007Player: Prebake Collision Meshes → Enable
PAS0027Player: Mipmap Stripping → Enable
descriptorIdFix
PAA4000Long AudioClip Load Type → Streaming
PAA4004AudioClip Decompress On Load → CompressedInMemory
PAA4008Preload Audio Data → off
PAA0004Texture anisotropic level → 1

Per-asset reconciliation (handled by the parser): loadType = Streaming if PAA4000 present, else CompressedInMemory if PAA4004; preloadAudioData=false if PAA4008. One reimport per asset.

Terminal window
bun .claude/skills/t1k-unity-optimize-project-auditor/scripts/parse-report.cjs <report.projectauditor> [--root <repoRoot>] [--include-submodules]

The parser defaults its repo root to the script’s own location, so it finds .gitmodules regardless of your current directory. Pass --root only if the repo layout is non-standard. If a project setting carries a warning field (e.g. URP asset name unparsable), surface it and do not emit a no-op fix for it. Returns JSON: projectSettings[], assets.apply[], assets.skippedSubmodule[], counts, absentTargets[], parsed URP assetNames. Submodule-owned assets are skipped by default — editing their importer .meta files dirties read-only submodule trees (see Hard rules). Re-run with --include-submodules only if the user explicitly opts in.

If error is present in the output, surface it and stop.

Present a table from the parser output:

  • Each project setting to change (descriptor title + recommendation from the report).
  • Each asset in assets.apply[] (path, target audio/texture change).
  • A separate “submodule-owned (skipped)” count + sample paths.
  • Note any absentTargets (target descriptors with 0 occurrences → nothing to do).

Use AskUserQuestion: Proceed (repo assets only) / Include submodule assets too / Project settings only / Abort. Never apply without an explicit choice.

Confirm the Unity Editor is open and reachable: t1k unity status must report ok (exit 14 means no Editor is open for this project; exit 4 means run the error.fix from t1k unity doctor). If the Editor is unavailable, fall back to report-only: output the full fix list + the C# the user could paste into a temp Editor script, and stop. Do not attempt edits.

Before any mutation, ensure a clean revert point. Commit any pending changes to the files about to change (pathspec form — never git add .), but do not let a clean tree abort the workflow:

Terminal window
git diff --quiet HEAD -- <UnityProject>/ProjectSettings \
&& echo "ProjectSettings clean — revert point is current HEAD" \
|| git commit -m "chore: checkpoint before project-auditor-optimize" -- <UnityProject>/ProjectSettings

If the tree is already clean, the current HEAD is the revert point — proceed. The revert path after apply is git restore/git checkout of ProjectSettings/ and the changed .meta files.

6. Apply via temp Editor script + menu item

Section titled “6. Apply via temp Editor script + menu item”

Populate the C# template below from the parser JSON, then drive it through t1k unity:

  1. Write the script: use the Write tool to create Assets/Editor/ProjectAuditorApply.cs from the filled template. It exposes one [MenuItem("Tools/Project Auditor/Apply Optimizations")] static method that runs project settings first, then assets in batches of ≤25 (split into helper methods or loop — the menu method calls them in order). Include a read-back+Debug.Log summary at the end (used by step 7).
  2. Compile: t1k unity recompile (exit 6 lists file:line errors in data.errors), then t1k unity console --level error — confirm zero compile errors before triggering.
  3. Trigger: t1k unity menu 'Tools/Project Auditor/Apply Optimizations'.
  4. Check: t1k unity console to catch runtime errors and read the summary Debug.Log lines.
  5. Clean up: delete the temp script and its .meta (rm Assets/Editor/ProjectAuditorApply.cs*), then t1k unity refresh --compile. Leave no scaffolding behind.

PlayerSettings, AudioManager.asset speaker mode, and URP m_SupportsHDR have no dedicated t1k unity verb, so the temp Editor script is the canonical path that covers all 10 fixes uniformly.

Read the summary Debug.Log lines emitted by the apply script (PlayerSettings getters; a sampled importer re-read) from t1k unity console and confirm the target values. Report a summary. Recommend the user re-run Project Auditor to confirm the issues are cleared.

Temp Editor script template (fill arrays from parser output)

Section titled “Temp Editor script template (fill arrays from parser output)”

Write the whole class to Assets/Editor/ProjectAuditorApply.cs, fill the arrays from the parser JSON, compile via t1k unity recompile, then fire the menu item via t1k unity menu 'Tools/Project Auditor/Apply Optimizations'. Delete the file when done (step 6.5). Emit only the project-setting lines present in projectSettings[]. Full template: references/apply-script-template.md.

Only parsing the report is mechanical:

StepAgent
Run scripts/parse-report.cjs on the .projectauditor report and read the issue listt1k-fact-fetcher
Decide which of the 10 fixes to apply and apply them via t1k unity behind the dry-run and confirmation gatereasoning tier — t1k-unity-base-optimizer; each is a write to project settings
  • Header lines: the .projectauditor file is PROJECT_AUDITOR_REPORT\n<ver>\n then JSON. The parser handles this; don’t JSON.parse the raw file.
  • descriptorId is the stable key (PAS*/PAA*) — match on it, not on the human description string (which embeds asset names and changes per item).
  • Submodule .meta dirtying: importer changes write .meta files. Assets under submodule prefixes are skipped by default. The parser reads the live .gitmodules, so this list stays correct automatically. Fixing those assets belongs in the submodule’s own repo.
  • Speaker Mode: no PlayerSettings API — edit AudioManager.asset via SerializedObject. Use (int)AudioSpeakerMode.Mono rather than a hardcoded int; confirm the property name Default Speaker Mode in the project’s Unity version (Unity 6 uses this name, NOT m_SpeakerMode).
  • URP supportsHDR is get-only in code — set m_SupportsHDR through SerializedObject. There may be multiple URP assets (per quality tier); only touch the filenames the report flagged.
  • preloadAudioData moved into per-platform AudioImporterSampleSettings (Unity 2022+/6). Set it on defaultSampleSettings; if platform overrides exist they may need the same change.
  • One reimport per asset: apply all of an asset’s audio changes, then a single SaveAndReimport().
  • Exit 7 during apply (Editor unreachable, e.g. domain reload) ≠ failure; the facade already retried once. Fixes are idempotent (set-to-target) — re-run safely. Never kill/restart the Editor (see rules/unity-forbidden-operations.md).
  • Reversible: every fix is a settings/importer change. The git checkpoint in step 5 is the revert path.