argent-metro-debugger
software-mansion/argent
Debug React Native (Metro) and Chromium apps via Chrome DevTools Protocol with component inspection and console access.
What is argent-metro-debugger?
Connects to JavaScript runtimes via CDP to debug React Native apps on iOS/Android through Metro, or Chromium-based apps (Electron, browsers). Use when you need to inspect React components, evaluate JavaScript, read console logs, or diagnose runtime issues.
- Connect to Metro dev server or Chromium CDP and retrieve runtime diagnostics
- Inspect React component tree with names, hierarchy, bounding rects, and tap coordinates
- Inspect individual elements by screen coordinates and trace to source file:line
- Evaluate arbitrary JavaScript expressions in the running app
- Access console logs via log registry with grep and read capabilities
- Reload Metro-connected apps or restart individual apps by device ID
How to install argent-metro-debugger
npx skills add https://github.com/software-mansion/argent --skill argent-metro-debugger- Metro dev server running on localhost:8081 (or custom port) for React Native apps
- React Native app connected to Metro with at least one CDP target
- For Android: adb reverse tcp:8081 tcp:8081 set up to forward Metro port from device
- For Chromium apps: Electron app booted via boot-device or Chromium browser exposing CDP port (9222 or ARGENT_CHROMIUM_PORTS)
How to use argent-metro-debugger
- 1.Run debugger-status to verify Metro connection and list available CDP targets
- 2.Call debugger-connect with the correct port and device_id to establish a session
- 3.Use debugger-component-tree to see the full React fiber hierarchy and layout
- 4.Call debugger-inspect-element with x,y logical pixel coordinates to trace an element to its source
- 5.Use debugger-evaluate to run JavaScript expressions in the runtime
- 6.Call debugger-log-registry to get a log summary, then grep or read the flat log file for details
- 7.Use debugger-reload-metro to reload all connected apps, or restart-app to relaunch a specific app
Use cases
- Debugging layout issues by inspecting component tree and tap targets on iOS/Android devices
- Tracing a visible UI element back to its source file and component definition
- Evaluating JavaScript expressions to test logic or inspect state in a running React Native app
- Collecting and filtering console logs from a connected device or Chromium app
- Diagnosing Metro connection failures or app runtime problems
- React Native developers debugging iOS and Android apps
- Frontend engineers using Electron or Chromium-based applications
- QA engineers inspecting component hierarchies and tap targets on mobile devices
- Developers troubleshooting runtime errors and console output
argent-metro-debugger FAQ
Run debugger-status or list-devices. The device_id is the logicalDeviceId (iOS Simulator UDID or Android serial) returned by those commands. Always include device_id in debugger calls to target the correct device.
Run 'adb -s <serial> reverse tcp:8081 tcp:8081' to forward the Metro port from the device to the host. If adb drops or the device restarts, re-run the command. This is required for Android emulators and physical devices.
debugger-component-tree shows the full React fiber hierarchy and layout overview. debugger-inspect-element targets a specific screen coordinate (x, y) and traces that element back to its source file and component definition. Use component-tree for orientation, inspect-element for source tracing.
A subset of tools work on Chromium: debugger-connect, debugger-status, debugger-evaluate, debugger-log-registry, view-network-logs, and view-network-request-details. React Native-specific tools like debugger-component-tree, debugger-inspect-element, and react-profiler-* are not supported on Chromium.
Call restart-app with the device_id and bundleId to terminate and relaunch the app. Then run debugger-status to verify reconnection. If the issue persists, check that Metro is still running and the device can reach it (especially on Android—verify adb reverse is set up).
Full instructions (SKILL.md)
Source of truth, from software-mansion/argent.
name: argent-metro-debugger description: Debug a JS runtime via CDP using argent debugger tools. Primary path is React Native via Metro (iOS / Android); a subset of the tools (debugger-connect, debugger-status, debugger-evaluate, debugger-log-registry) also drive a Chromium (CDP) app's renderer (an Electron app, or any Chromium browser exposing CDP) through the same surface. Use when connecting to the runtime, inspecting React components, reading console logs, or evaluating JavaScript.
1. Prerequisites
For React Native (iOS / Android): requires Metro dev server running (default localhost:8081) and a React Native app connected to Metro (at least one CDP target). Verify via debugger-status.
For Chromium (CDP): requires a Chromium/CDP app already available — an Electron app booted via boot-device with electronAppPath, or any Chromium browser exposing a CDP port (auto-discovered by list-devices on 9222 / ARGENT_CHROMIUM_PORTS). The debugger re-uses the page CDP session — port is ignored, device_id is the chromium-cdp-<port> value from list-devices / boot-device. Only debugger-connect, debugger-status, debugger-evaluate, debugger-log-registry, view-network-logs, and view-network-request-details work on Chromium (the latter two read the browser's native CDP Network recording for the active tab instead of the Metro-injected fetch interceptor); debugger-component-tree, debugger-reload-metro, debugger-inspect-element, and the react-profiler-* / profiler-* tools are RN-only and reject Chromium at the capability gate with Tool 'X' is not supported on chromium app.
Android: reverse port for Metro
Android emulators and physical devices do not resolve the host's localhost by default. Before the RN app can reach Metro, forward port 8081 (or whichever port Metro is on) from the device back to the host:
adb -s <serial> reverse tcp:8081 tcp:8081
<serial> is the Android serial from list-devices. Once reversed, the app on the device connects to Metro just like an iOS simulator does, and all debugger-* / network-* / react-profiler-* tools work unchanged. If the device restarts or adb drops, re-run the command. A failing Metro connection on Android almost always means adb reverse has not been done or has been lost.
2. Tool Overview
All tools accept port (default 8081) AND device_id (the iOS Simulator UDID or Android serial, a.k.a. logicalDeviceId — the CDP-reported id that matches the device). Always make sure you target the correct app on the correct device.
One Metro port can serve multiple connected devices (e.g. two simulators on localhost:8081, or an iOS simulator alongside an Android emulator with adb reverse set up). device_id pins every debugger/network/profiler call to a specific device so sessions do not collide.
Connect & diagnostics
| Tool | Purpose |
|---|---|
debugger-connect | Connect to the JS runtime's CDP (Metro on iOS / Android; the page CDP session on Chromium). Returns port, projectRoot (empty on Chromium), deviceName, appName, logicalDeviceId, isNewDebugger, connected. The returned logicalDeviceId is the device_id for every subsequent debugger call. |
debugger-status | Like connect + loadedScripts, enabledDomains, sourceMapReady (no-op on Chromium). Use to diagnose. |
Reload & recovery
| Tool | Purpose |
|---|---|
debugger-reload-metro | Reload all connected apps (like pressing "r" in Metro terminal). Needs a CDP target. |
restart-app | Terminate and relaunch the app by device id and bundleId. Use when app lost Metro connection. |
Inspection & console
| Tool | Purpose |
|---|---|
debugger-component-tree | Full React fiber tree (names, depth, bounding rects, tap coordinates). |
debugger-inspect-element | Inspect at (x, y) using logical pixel coordinates (not normalized 0-1): component hierarchy with source file:line and code fragment. See references/source-maps.md. |
debugger-log-registry | Get log summary (counts, clusters, file path). Then use Grep/Read on the flat log file for details. |
debugger-evaluate | Run a JS expression in the app runtime. |
3. Component Inspection
debugger-component-tree vs debugger-inspect-element
debugger-component-tree | debugger-inspect-element | |
|---|---|---|
| Best for | Layout overview; finding tap targets; user-defined component hierarchy | Identifying a visible element and tracing it to its source file |
| Use when | "What's on screen and where?" | "What component is this and where is it defined?" |
Both can point to source files, but inspect-element is purpose-built for source tracing. component-tree is for orientation and tap-target discovery.
includeSkipped guidance
Applies to both debugger-component-tree and debugger-inspect-element. Set to true only when debugging filter behavior — e.g., an expected component is missing from output, or you need to inspect a very specific branch of the tree (not just an overview).
Warning: Output can be very large. Always combine with
maxNodes(component-tree) ormaxItems(inspect-element) and increase it incrementally (e.g., start at 50, then grow). Do not useincludeSkippedwithout a limit on large apps.
4. Golden Rules
debugger-statusfirst when something fails — it runs discovery, connection, and returns diagnostics.- "No CDP targets" → get the app to connect to Metro — use
restart-appon the device, then retrydebugger-status. - Never assume one failure is permanent — follow recovery steps before asking the user. For starting Metro and full failure recovery, see
argent-react-native-app-workflowandreferences/failure-scenarios.md.
5. Reading Console Logs (Log Registry)
Logs are written to a flat log file on disk. Use the log-registry → grep pattern instead of reading logs inline.
Workflow
- Call
debugger-log-registry— returns:file(log path),totalEntries,byLevel,clusters(top message groups with counts and source file info) - Search the file using
GreporReadwith patterns from the response.
Large log files: If
totalEntriesexceeds 10 000, delegate the grep exploration to anExploresubagent — pass it the file path, the entry format, and the patterns you need.
Flat log format
One entry per line — fields (whitespace-separated, | delimiter before message)
| Field | Example | Notes |
|---|---|---|
[L:<id>] | [L:42] | Unique grep anchor |
<timestamp> | 2026-03-17T14:30:00.000Z | ISO 8601 |
<LEVEL> | ERROR, WARN , LOG | Uppercase, padded to 5 chars |
<source> | src/api/user.ts:42 or - | Relative path from source map; - if unavailable |
<message> | Failed login attempt | Full message; embedded newlines replaced with space |
Source attribution (file + line) is also available in clusters returned by debugger-log-registry.
Log files and messages can be large - Always scope your search, treat the file like a database, not a document.
When reading from the log file:
- Never
Readthe log file directly. Usegrepor shell commands with limits using the above file format tips. - Default to
-m 50unless you need more. - Use
tail -Nrecent entries. clusters[].messagegives you the exact text which you may look for
If the file is too large Delegate to an
Exploresubagent with the file path, the format spec above, and the specific patterns you need.
Quick Reference
| Action | Tool |
|---|---|
| Diagnose / check connection | debugger-status |
| Connect to CDP (Metro / Chromium) | debugger-connect |
| Reload JS (already connected) | debugger-reload-metro |
| Relaunch app on device | restart-app |
| Inspect component at point | debugger-inspect-element |
| Full component tree | debugger-component-tree |
| Console log overview | debugger-log-registry (summary + log file path for Grep/Read) |
| Evaluate JS | debugger-evaluate |
Related skills
More from software-mansion/argent and the wider catalog.
argent-android-emulator-setup
Set up and boot Android emulators, connect via adb, and prepare for UI automation.
argent-device-interact
Interact with iOS simulators, Android emulators, and Chromium apps using unified gesture and UI automation tools.
argent-react-native-app-workflow
Step-by-step workflows for developing and debugging React Native apps on iOS and Android emulators.
argent-ios-simulator-setup
Set up and connect to iOS simulators using argent MCP tools for automated testing and interaction.
argent-test-ui-flow
Autonomously test iOS/Android app UI flows with interact-screenshot-verify loops using argent MCP tools.
argent-react-native-profiler
Profile React Native Hermes apps to measure re-render and CPU performance with argent profiler tools.