本文へ移動
cccskills
無料GitHub で公開

flight-profiler-getglobal

Inspect Python module global field or class static field value in a running Python process. Use this for safe, read-only inspection of global variables, configuration objects, or class-level state.

インストール方法を見る

含まれるファイル(1)

  • SKILL.md9.8 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

flight-profiler-getglobal

Inspect Python module global field or class static field value. A safe, read-only way to check configuration, feature flags, counters, or any module-level / class-level state.

Prerequisites: Read the flight-profiler-attach skill first for platform requirements, installation, permissions, and connection details.

When to Use

  • You want to check the current value of a global variable or config setting
  • You need to inspect a class static field
  • You want a safe, read-only alternative to opening a console
  • You need to evaluate an expression on a global object

Usage

flight_profiler <pid> --cmd "getglobal module [class] field [options]" --no-color

Positional Arguments

  • module — the module name as it would be imported in the target process. For example, if the target code does from myapp.config import settings, then module is myapp.config. PyFlightProfiler locates the module via importlib.import_module. If you're unsure of the module name, run a separate command to resolve it first: flight_profiler <pid> --cmd "module /absolute/path/to/file.py" --no-color, then use the returned module name here.
  • class (optional) — class name for static field inspection
  • field — field name to inspect

Options

FlagDescriptionDefault
-x, --expand <value>Object tree expand level (1-6, or -1 for unlimited)2
-e, --expr <value>Expression to evaluate on the target. The variable target refers to the resolved field value.target
-r, --rawUse __str__ (equivalent to print(obj)) instead of default JSON serializationoff
-v, --verboseDisplay all nested items in list/dict without truncationoff

Choosing the Right -e Expression

-e directly controls what you see in the output. Always match the user's intent to the right expression — the default target shows the entire object.

User intent-e value
See the entire variabletarget (default)
See a specific dict keytarget['key']
See a nested fieldtarget['a']['b']
See an object attributetarget.attr
Get the length / countlen(target)
Check a conditiontarget['key'] == expected
List all keyslist(target.keys())

Output Format

getglobal returns immediately with a single result block:

  EXPR:       target
  TYPE:       <class 'dict'>
  VALUE:      {
                "database_url": "postgresql://localhost:5432/mydb",
                "debug": True,
                "max_connections": 10,
                "nested": {
                  "level1": {'level2': 'deep_value'}
                }
              }

Output Fields

FieldDescription
EXPRThe expression used to extract the displayed value (default target)
TYPEPython type of the expression result
VALUEThe value, formatted as JSON (or __str__ if -r)

When the expression fails (e.g., accessing a nonexistent attribute):

  EXPR:               target.nonexistent
  FAILED_REASON:      AttributeError: 'dict' object has no attribute 'nonexistent'

Examples

1. Module global variable (dict)

flight_profiler <pid> --cmd "getglobal __main__ config" --no-color
  EXPR:       target
  TYPE:       <class 'dict'>
  VALUE:      {
                "database_url": "postgresql://localhost:5432/mydb",
                "debug": True,
                "max_connections": 10,
                "nested": {
                  "level1": {'level2': 'deep_value'}
                }
              }

Note: at default expand level (-x 2), the nested.level1 dict is shown as a compact repr. Use -x 3 to expand deeper (see example 5).

2. Module global variable (simple type)

flight_profiler <pid> --cmd "getglobal __main__ counter" --no-color
  EXPR:       target
  TYPE:       <class 'int'>
  VALUE:      61

The value reflects the live state — counter was 42 at startup but has been incrementing.

3. Class static field

flight_profiler <pid> --cmd "getglobal __main__ AppConfig VERSION" --no-color
  EXPR:       target
  TYPE:       <class 'str'>
  VALUE:      "2.1.0"

4. Class static field (dict)

flight_profiler <pid> --cmd "getglobal __main__ AppConfig FEATURES" --no-color
  EXPR:       target
  TYPE:       <class 'dict'>
  VALUE:      {
                "caching": False,
                "logging": True,
                "metrics": True
              }

5. Deeper expand with -x 3

Expands nested objects one level deeper than default:

flight_profiler <pid> --cmd "getglobal __main__ config -x 3" --no-color
  EXPR:       target
  TYPE:       <class 'dict'>
  VALUE:      {
                "database_url": "postgresql://localhost:5432/mydb",
                "debug": True,
                "max_connections": 10,
                "nested": {
                  "level1": {
                    "level2": "deep_value"
                  }
                }
              }

Compare with example 1 — nested.level1.level2 is now fully expanded.

6. Expression — extract a specific field

Use -e to drill into the object without expanding the entire tree:

flight_profiler <pid> --cmd "getglobal __main__ config -e target['database_url']" --no-color
  EXPR:       target['database_url']
  TYPE:       <class 'str'>
  VALUE:      "postgresql://localhost:5432/mydb"

7. Expression — compute a value

flight_profiler <pid> --cmd "getglobal __main__ active_users -e len(target)" --no-color
  EXPR:       len(target)
  TYPE:       <class 'int'>
  VALUE:      5

8. Expression on class static field

flight_profiler <pid> --cmd "getglobal __main__ CacheManager _store -e target['user:1']" --no-color
  EXPR:       target['user:1']
  TYPE:       <class 'dict'>
  VALUE:      {
                "age": 30,
                "name": "alice"
              }

9. Raw mode -r (use __str__ instead of JSON)

flight_profiler <pid> --cmd "getglobal __main__ config -r" --no-color
  EXPR:       target
  TYPE:       <class 'dict'>
  VALUE:      {'database_url': 'postgresql://localhost:5432/mydb', 'debug': True, 'max_connections': 10, 'nested': {'level1': {'level2': 'deep_value'}}}

Entire dict on one line using Python's native __str__ representation.

10. Verbose mode -v

Shows all items in lists/dicts without truncation. Useful when collections are large and default output truncates them:

flight_profiler <pid> --cmd "getglobal __main__ active_users -v" --no-color
  EXPR:       target
  TYPE:       <class 'list'>
  VALUE:      [
                "alice",
                "bob",
                "charlie",
                "dave",
                "eve"
              ]

-e Expression Guide

The -e option accepts any valid Python expression. The variable target refers to the resolved global variable or class static field.

Common patterns:

# Default: show the entire variable
-e target

# Access a dict key
-e target['key']

# Access a nested field
-e target['nested']['level1']

# Access an attribute
-e target.attribute

# Get length
-e len(target)

# Get type
-e type(target)

# List comprehension
-e [k for k in target.keys()]

# Check a condition
-e target['debug'] == True

# Slice a list
-e target[:3]

Handling Command Output

  • Long output: if the inspected object is large (e.g., a big dict or deeply nested config), redirect the output to a file for the user to review later:
    flight_profiler <pid> --cmd "getglobal __main__ config -x 4 -v" --no-color > /tmp/getglobal_output.txt
    
  • Short output: if the result is brief (a single value, small dict, or simple type), display the full result directly to the user so they can see it immediately.

Handling Large Objects

When an object is too large to serialize or the output is truncated/incomplete:

  1. Prefer minimal extraction — use -e to extract only the fields you need, instead of the entire object:

    # Instead of serializing the entire config:
    -e target
    # Extract only the field you care about:
    -e target['database_url']
    -e target['nested']['key']
    -e type(target),len(target)
    
  2. Use -v (verbose) — if you do need the full object, add -v to disable truncation so all nested items in lists/dicts are shown completely.

Tips

  • getglobal is read-only and safe — it never modifies the target process state
  • Default expand level is 2 (deeper than watch's default of 1) — use -x 3 or higher for deeply nested objects
  • Use -e expressions to drill into nested objects without expanding the entire tree
  • -r (raw) uses __str__ (like print(obj)) — useful for objects with custom __str__ or when you want the native Python representation
  • For writable operations or complex logic, use console instead
  • Combine with module command if you only know the file path

Related Commands

  • console — interactive REPL for read-write access (getglobal is read-only and safer)
  • vmtool getInstances — find instances by class (getglobal accesses known variables)
  • watch — observe a function's inputs/outputs over time (getglobal is for point-in-time inspection)

Source Files

  • CLI plugin: flight_profiler/plugins/getglobal/cli_plugin_getglobal.py
  • Parser: flight_profiler/plugins/getglobal/getglobal_parser.py
  • Server plugin: flight_profiler/plugins/getglobal/server_plugin_getglobal.py

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

同じリポジトリのスキル

概要と使いどころ

Prerequisites and connection details for attaching to a live Python process with PyFlightProfiler. Read this skill first before using any other PyFlightProfiler command (watch, trace, stack, perf, etc.).

日本語の概要は準備中です。原文の説明を表示しています。

alibaba/PyFlightProfiler462026年9月22日 更新

Translate a file path to its Python module name in a running Python process. Use this when you know a file path but need the module name for commands like watch, trace, or reload.

日本語の概要は準備中です。原文の説明を表示しています。

alibaba/PyFlightProfiler462026年9月22日 更新

Hot-reload a Python function implementation from the latest file content without restarting the process. Use this to apply code fixes live after identifying a bug with watch/trace.

日本語の概要は準備中です。原文の説明を表示しています。

alibaba/PyFlightProfiler462026年9月22日 更新

Inspect stack frames of a running Python process including thread stacks, native C-level frames, and async coroutine stacks. Use this to see what each thread is currently doing and diagnose hangs, deadlocks, or stuck async tasks.

日本語の概要は準備中です。原文の説明を表示しています。

alibaba/PyFlightProfiler462026年9月22日 更新

Trace execution time of Python method invocations in a live process with call stack visualization. Use this to see a hierarchical call tree showing which sub-calls are slow and where time is spent within a function.

日本語の概要は準備中です。原文の説明を表示しています。

alibaba/PyFlightProfiler462026年9月22日 更新

Inspect live Python class instances in a running process — find all instances of a class, examine their attributes/state, or invoke methods on them. Also supports forcing GC. Use this when you need to probe object-level runtime state beyond what watch/getglobal can provide.

日本語の概要は準備中です。原文の説明を表示しています。

alibaba/PyFlightProfiler462026年9月22日 更新

alibaba のスキルをすべて見る

このスキルの問題を報告する