t1k:unity:optimize:project-auditor
| Field | Value |
|---|---|
| Module | optimize |
| Version | 2.35.6 |
| Effort | medium |
| Tools | — |
Keywords: audio-import, mobile-perf, optimize, player-settings, project-auditor, projectauditor, texture-aniso, urp-hdr
How to invoke
Section titled “How to invoke”/t1k:unity:optimize:project-auditorOptimize Project via Project Auditor
Section titled “Optimize Project via 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.cswith[MenuItem]methods →t1k unity recompilecompiles it →t1k unity menu 'Tools/Project Auditor/Apply Optimizations'triggers it → delete the script afterward. (One multi-statementt1k unity eval --filewould 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.projectauditorreport you already have.
Required input
Section titled “Required input”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).
The 10 fixes (SSOT)
Section titled “The 10 fixes (SSOT)”ProjectSetting (applied once each)
Section titled “ProjectSetting (applied once each)”| descriptorId | Fix |
|---|---|
PAS0033 | Audio Speaker Mode → Mono |
PAS1010 | URP HDR → off on the flagged URP asset(s) |
PAS0034 | Player: Use incremental GC → Enable |
PAS0008 | Player: Optimize Mesh Data → Enable |
PAS0007 | Player: Prebake Collision Meshes → Enable |
PAS0027 | Player: Mipmap Stripping → Enable |
AssetIssue (per asset, reconciled)
Section titled “AssetIssue (per asset, reconciled)”| descriptorId | Fix |
|---|---|
PAA4000 | Long AudioClip Load Type → Streaming |
PAA4004 | AudioClip Decompress On Load → CompressedInMemory |
PAA4008 | Preload Audio Data → off |
PAA0004 | Texture 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.
Workflow
Section titled “Workflow”1. Parse the report (facts)
Section titled “1. Parse the report (facts)”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.
2. Dry-run (mandatory)
Section titled “2. Dry-run (mandatory)”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).
3. Confirm (HARD gate)
Section titled “3. Confirm (HARD gate)”Use AskUserQuestion: Proceed (repo assets only) / Include submodule assets too /
Project settings only / Abort. Never apply without an explicit choice.
4. Preconditions
Section titled “4. Preconditions”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.
5. Git checkpoint
Section titled “5. Git checkpoint”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:
git diff --quiet HEAD -- <UnityProject>/ProjectSettings \ && echo "ProjectSettings clean — revert point is current HEAD" \ || git commit -m "chore: checkpoint before project-auditor-optimize" -- <UnityProject>/ProjectSettingsIf 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:
- Write the script: use the
Writetool to createAssets/Editor/ProjectAuditorApply.csfrom 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.Logsummary at the end (used by step 7). - Compile:
t1k unity recompile(exit 6 listsfile:lineerrors indata.errors), thent1k unity console --level error— confirm zero compile errors before triggering. - Trigger:
t1k unity menu 'Tools/Project Auditor/Apply Optimizations'. - Check:
t1k unity consoleto catch runtime errors and read the summaryDebug.Loglines. - Clean up: delete the temp script and its
.meta(rm Assets/Editor/ProjectAuditorApply.cs*), thent1k unity refresh --compile. Leave no scaffolding behind.
PlayerSettings,
AudioManager.assetspeaker mode, and URPm_SupportsHDRhave no dedicatedt1k unityverb, so the temp Editor script is the canonical path that covers all 10 fixes uniformly.
7. Verify
Section titled “7. Verify”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.
Executed by
Section titled “Executed by”Only parsing the report is mechanical:
| Step | Agent |
|---|---|
Run scripts/parse-report.cjs on the .projectauditor report and read the issue list | t1k-fact-fetcher |
Decide which of the 10 fixes to apply and apply them via t1k unity behind the dry-run and confirmation gate | reasoning tier — t1k-unity-base-optimizer; each is a write to project settings |
Hard rules
Section titled “Hard rules”- Header lines: the
.projectauditorfile isPROJECT_AUDITOR_REPORT\n<ver>\nthen JSON. The parser handles this; don’tJSON.parsethe raw file. descriptorIdis the stable key (PAS*/PAA*) — match on it, not on the human description string (which embeds asset names and changes per item).- Submodule
.metadirtying: importer changes write.metafiles. 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
PlayerSettingsAPI — editAudioManager.assetviaSerializedObject. Use(int)AudioSpeakerMode.Monorather than a hardcoded int; confirm the property nameDefault Speaker Modein the project’s Unity version (Unity 6 uses this name, NOTm_SpeakerMode). - URP
supportsHDRis get-only in code — setm_SupportsHDRthroughSerializedObject. There may be multiple URP assets (per quality tier); only touch the filenames the report flagged. preloadAudioDatamoved into per-platformAudioImporterSampleSettings(Unity 2022+/6). Set it ondefaultSampleSettings; 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.