본문으로 건너뛰기
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.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

연동 도구PostgreSQL
설치 방법 보기

포함된 파일(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

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

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의 스킬 모두 보기

이 스킬의 문제 신고