Back to Skills

decode-minified-js-gates

pjt222
Updated 6 days ago
13 views
17
2
17
View on GitHub
Developmentgeneral

About

This skill analyzes minified JavaScript to identify and classify feature flag gate implementations, extracting their variant types, default values, and logical structures. It produces a detailed mechanics record useful when flag behavior is unclear or multiple reader libraries are used. Key capabilities include detecting various sync/async gate patterns and parsing config-object schemas distinct from simple boolean gates.

Quick Install

Claude Code

Recommended
Primary
npx skills add pjt222/agent-almanac -a claude-code
Plugin CommandAlternative
/plugin add https://github.com/pjt222/agent-almanac
Git CloneAlternative
git clone https://github.com/pjt222/agent-almanac.git ~/.claude/skills/decode-minified-js-gates

Copy and paste this command in Claude Code to install this skill

Documentation

解閘

讀 minified JS 中旗之 call-site 脈絡→生閘機之錄:何變體、何默、何合取、何用。probe-feature-flag-state 答「閘開抑閉?」,此技答先問——「閘何為?」

  • sweep-flag-namespace 出之旗,名不能識
  • binary 用一以上之閘讀函→須識某旗用何
  • 閘之「默」似非布爾({}null、數字字面)→須解真讀者變體
  • 疑為 kill-switch(倒閘)而名不能證
  • predicate 以 && 合多閘→須先列共閘乃可探之

  • :minified JS bundle(.js.mjs.bun
  • :欲解之旗字串字面
  • :前次解出之已知讀函名單→助步二
  • :脈絡窗大小覆寫;默為旗前 300 字、後 200 字

Step 1: Extract the Context Window

覓旗字串→於每出現取不對稱窗。前脈絡(旗前)藏讀函名;後脈絡(旗後)藏默值與合取。

BUNDLE=/path/to/cli/bundle.js
FLAG=acme_widget_v3                   # synthetic placeholder
PRE=300
POST=200

# All byte offsets where the flag string occurs
grep -boE "\"${FLAG}\"" "$BUNDLE" | cut -d: -f1 > /tmp/decode-offsets.txt
wc -l /tmp/decode-offsets.txt

# Capture an asymmetric window per occurrence
while read -r offset; do
  start=$((offset - PRE))
  [ "$start" -lt 0 ] && start=0
  length=$((PRE + POST))
  echo "=== offset $offset ==="
  dd if="$BUNDLE" bs=1 skip="$start" count="$length" 2>/dev/null
  echo
done < /tmp/decode-offsets.txt > /tmp/decode-windows.txt

less /tmp/decode-windows.txt

速行之初掃,可用 grep -oE 配 Perl negative-lookbehind,一管捕同窗。

得:每出現一脈絡窗,各約 500 字。多次出現常共讀函而異於默或合取——各別察之。

敗:bundle 過巨而 dd-逐出現不堪(binary > 100MB 或出現繁)→改 rg -B 5 -A 3 "$FLAG" "$BUNDLE" 為結構化近似。窗似亂→bundle 或為 UTF-16 或非 ASCII 分隔;用 iconv 或視為二進制。

Step 2: Identify the Reader Variant

minified 閘庫常露 4–6 讀者變體,語義各異。讀函名為首兆;調簽為驗者。

變體之屬(合成名——以汝 bundle 中真 minified 識別替之):

VariantSynthetic shapeReturnsCommon usage
Sync booleangate("flag", false) or gate("flag", true)booleanStandard on/off feature switches
Sync config-objectfvReader("flag", {key: value})JSON objectStructured config (delays, allowlists, model names)
Bootstrap-aware TTLttlReader("flag", default, ttlMs)boolean (cached)Startup-path gates before remote config arrives
Truthy-onlytruthyReader("flag")truthy/falsyQuick checks; no explicit default
Async bootstrapasyncReader("flag")Promise<boolean>Gates resolved post-bootstrap
Async bridgebridgeReader("flag")Promise<boolean>Bridge/relay-channel gates with separate evaluation path

各脈絡窗對變體 pattern 比之:

# Test for variant patterns. Replace the synthetic reader names with the
# actual minified identifiers found in the bundle.
grep -oE '\b(gate|fvReader|ttlReader|truthyReader|asyncReader|bridgeReader)\("acme_widget_v3"' /tmp/decode-windows.txt | sort | uniq -c

同旗現多變體(罕有實——啟動同步讀、bootstrap 後異步讀),則各出現別錄其變體。探之果或異。

得:每閘調出現有一變體標。掃中諸變體計→生 binary 級分布(如「60% sync boolean、30% config-object、10% TTL」)。

敗:脈絡窗無可識讀者 pattern→或非真閘調,重核 sweep-flag-namespace 步二之分類。窗有不在此屬之讀名→記為新變體於研究之物,斷其是否別處置。

Step 3: Extract the Default Value

默乃讀者第二位參(truthy-only / async 變體則無)。捕字面——falsetruenull0、字串、JSON config 物。

# Boolean default extraction (sync boolean and TTL variants)
grep -oE '\b(gate|ttlReader)\("acme_widget_v3",\s*(true|false)' /tmp/decode-windows.txt

# Config-object default — match the opening brace and capture until the
# matching brace at the same nesting depth. For minified bundles this is
# usually safe with a non-greedy match because objects rarely span lines.
grep -oE 'fvReader\("acme_widget_v3",\s*\{[^}]*\}' /tmp/decode-windows.txt

# Numeric default (rare but real for TTL or threshold gates)
grep -oE '\b(gate|ttlReader)\("acme_widget_v3",\s*[0-9]+' /tmp/decode-windows.txt

config 物之默→察其 JSON 之構,鍵名常示閘之意(如 {maxRetries: 3, timeoutMs: 5000} 為 retry 政之 config,非功能 toggle)。

得:每出現一準確字面默。布爾無歧;config 物須人讀其構。

敗:config 物之配對大括號逾窗→增步一之後脈絡。默似變量引(如 gate("flag", x))→默為運行時算,記為 DYNAMIC,以 probe-feature-flag-state 探真返值。

Step 4: Detect Conjunctions and Kill Switches

多閘參於合 predicate。合取(&&)與倒(!)變閘之效用。

# Conjunction detection: gate-call followed by `&&` and another gate-call
# within the same predicate window
grep -oE '(gate|fvReader|ttlReader|truthyReader|asyncReader|bridgeReader)\("acme_widget_v3"[^)]*\)\s*&&\s*(gate|fvReader|ttlReader|truthyReader|asyncReader|bridgeReader)\("acme_[a-zA-Z0-9_]+"' /tmp/decode-windows.txt

# Kill-switch detection: leading `!` before the gate-call
grep -oE '!\s*(gate|fvReader|ttlReader|truthyReader|asyncReader|bridgeReader)\("acme_widget_v3"' /tmp/decode-windows.txt

每見之合取→列其共閘旗名。其今入探之範圍——目標旗之決依共閘者,獨探目標生不全之態。

每見之倒→閘機錄中標其為 kill-switch。kill-switch 倒默之意:kill-switch 之 default=false 乃「默開」(!false === true),常閘之 default=false 乃「默閉」。

得:每出現有合取單(或空)與倒之布爾標。

敗:合取逾 2 共閘→predicate 繁,regex 失構。人讀脈絡窗→於閘機錄中字面記其 predicate 之形。

Step 5: Classify the Gate's Role

合步二至四為角色之分。角色驅異探策與異整合險。

RoleSignatureImplication
Feature switchsync boolean, no inversion, no conjunctionStandard on/off; probe directly
Config providersync config-object (fvReader)Read returned object; default-empty {} ≠ feature off
Lifecycle guardbootstrap-aware TTL or async bootstrapState depends on bootstrap timing; probe at multiple points
Kill switchinverted gate, default-falseFeature on for users by default; flag flips it OFF
Conjunction memberany variant with && co-gateCannot evaluate alone; co-gates are part of the probe scope
Bridge gateasync bridge variantProbe must occur over the bridge channel, not the main path

得:每閘調出現一首要角色。某旗於諸出現中現多角(如此 call-site 為 feature switch、彼為合取員)→各別錄之。

敗:角色不入此表→binary 用未錄之閘庫。以合成識別添一行,貢此變體還此技(或項目擴展),以惠後察者。

Step 6: Produce the Gate-Mechanics Record

合每旗之發現為結構化錄。JSONL 便也,每旗為一行,易與 sweep-flag-namespace 錄合。

{"flag":"acme_widget_v3","variant":"sync_boolean","default":false,"role":"feature_switch","conjunctions":[],"inverted":false,"occurrences":3}
{"flag":"acme_retry_policy","variant":"sync_config_object","default":{"maxRetries":3,"timeoutMs":5000},"role":"config_provider","conjunctions":[],"inverted":false,"occurrences":1}
{"flag":"acme_legacy_path","variant":"sync_boolean","default":false,"role":"kill_switch","conjunctions":[],"inverted":true,"occurrences":2}
{"flag":"acme_beta_feature","variant":"sync_boolean","default":false,"role":"conjunction_member","conjunctions":["acme_beta_program_active"],"inverted":false,"occurrences":1}

閘機錄入 probe-feature-flag-state 步二(gate-vs-event 分辨):變體+角色+合取單→決何觀為 LIVE / DARK / INDETERMINATE 之證。

得:每旗一 JSONL 錄(或每旗-出現一錄,若同旗有異機)。錄可重——同 binary 復行此法生同錄。

敗:諸行錄異→上游某步非定。多為步一之 regex 漏取或過取。campaign 期間鎖 regex。

  • Step 1 produces one context window per flag occurrence; windows are ~500 chars
  • Step 2 tags each occurrence with exactly one reader variant from the taxonomy
  • Step 3 captures the exact default literal (boolean, config-object, or DYNAMIC)
  • Step 4 surfaces all conjunctions and kill-switch inversions present in the windows
  • Step 5 assigns one role per occurrence, drawn from the role table
  • Step 6 produces a JSONL gate-mechanics record that diffs cleanly across re-runs
  • All worked examples use synthetic placeholders (acme_*, gate, fvReader, etc.) — no real flag names, real reader names, or real config-object schemas
  • The record is consumable by probe-feature-flag-state (same flag identifiers, compatible field names)

  • 讀「默」為「為」default=true 之閘乃「此 binary 中默開」,server 覆寫或翻之。默告基線;運探(probe-feature-flag-state)告態。
  • 混 config 物空默與功能閉fvReader("flag", {}) 默返空物——而旗 (閘為 truthy)。視 {} 為「閉」→誤分 config-provider 為 feature switch。
  • 失 kill-switch:閘調前之 ! 倒其意。略步四→錄言「default=false,默閉」而真為「default=false,因倒故默開」。
  • 探合取之半:predicate 為 acme_widget_v3 && acme_user_in_cohort,獨探 acme_widget_v3 得 LIVE 不證功能 live——合取或仍以 cohort 旗閉之。
  • 信讀名越版:minified 識別主版間或更。步二之屬以 (調形、返型、默位)非以名分。binary 版更→新解中重導讀名。
  • 窗過窄:200/100 之分失逾 300 字之 config 物默。300/200 或 400/300 較安;唯 bundle 巨而窗費要時乃緊之。
  • 泄真讀名:minified 讀名似亂碼(abYc1)→似可字面貼。仍為發現,公開方法前以合成佔位替之。

  • probe-feature-flag-state — uses the gate-mechanics record to interpret runtime observations
  • sweep-flag-namespace — produces the candidate flag set this skill decodes
  • monitor-binary-version-baselines — tracks reader-name changes across binary versions; re-derive Step 2 patterns when baselines flip
  • redact-for-public-disclosure — how to publish gate-decoding methodology without exposing real reader names or schemas
  • conduct-empirical-wire-capture — validates the gate-mechanics record against runtime behavior

GitHub Repository

pjt222/agent-almanac
Path: i18n/wenyan-ultra/skills/decode-minified-js-gates
0
agentsagentskillsai-assisted-developmentclaude-codeskillsteams

Related Skills

qmd

Development

qmd is a local search and indexing CLI tool that enables developers to index and search through local files using hybrid search combining BM25, vector embeddings, and reranking. It supports both command-line usage and MCP (Model Context Protocol) mode for integration with Claude. The tool uses Ollama for embeddings and stores indexes locally, making it ideal for searching documentation or codebases directly from the terminal.

View skill

subagent-driven-development

Development

This skill executes implementation plans by dispatching a fresh subagent for each independent task, with code review between tasks. It enables fast iteration while maintaining quality gates through this review process. Use it when working on mostly independent tasks within the same session to ensure continuous progress with built-in quality checks.

View skill

mcporter

Development

The mcporter skill enables developers to manage and call Model Context Protocol (MCP) servers directly from Claude. It provides commands to list available servers, call their tools with arguments, and handle authentication and daemon lifecycle. Use this skill for integrating and testing MCP server functionality in your development workflow.

View skill

adk-deployment-specialist

Development

This skill deploys and orchestrates Vertex AI ADK agents using A2A protocol, managing AgentCard discovery, task submission, and supporting tools like Code Execution Sandbox and Memory Bank. It enables building multi-agent systems with sequential, parallel, or loop orchestration patterns in Python, Java, or Go. Use it when asked to deploy ADK agents or orchestrate agent workflows on Google Cloud.

View skill