Skip to main content

The Core Problem

A common debugging mistake is deploying five times to fix the same bug, when a single log line plus one deployment would have shown you the root cause immediately. If you’re patching against test failures rather than the actual return shape, stop and add a console.log first — then deploy once.

The 5-Step Debug Loop

1

Add a console.log to the suspicious spot

Log the actual value — not a guess, the real thing:
Log the entire object so you see the actual shape, not what you assumed it would be.
2

Push to sandbox (not production)

Or use sandbox mode for even faster iteration — no push needed:
In sandbox mode, lua chat compiles and uses your local code directly. Use this for rapid iteration before committing to a push.
3

Send ONE test message

Or in interactive mode:
Send the minimum message needed to trigger the tool. Don’t run a full conversation — you need one clean execution to inspect.
4

Check logs immediately

Your console.log output appears in the log message body. Look for the 🔍 DEBUG or ℹ️ INFO entries — they contain your logged values.Example output:
Now you can see the exact shape of what was returned and fix accordingly.
5

Fix once, not five times

You now know:
  • Exact shape of the return value
  • Which fields exist (and which don’t)
  • What the actual values look like
Fix the code, push once, verify with lua logs. Repeat until correct.

Suppressing CLI hints

All post-action hints can be silenced with:
Set LUA_NO_HINTS=true (or yes) in your shell profile or CI environment to disable hints globally. This is useful in CI/CD pipelines that capture only command output.

Reading lua logs Output

Log entry anatomy

Log types

Filter by component type

When to Use lua test vs lua chat vs lua logs

console.log Debugging Patterns

Log a full API return value

Log individual entries

Log before and after transformation

Common Bugs and How to Spot Them

results.data would be undefined — there is no .data wrapper on the array. Use results[0].data.title for the entry payload, or results[0].title via the Proxy shortcut.

Bug: entry.title is undefined (Data.get)

entry.title would be undefinedData.get entries are raw, not proxied. Use entry.data.title.
results.data doesn’t exist on ProductSearchInstance. Use results.products or results.map(p => p.name).

Removing Debug Logs Before Production

Once the bug is fixed, clean up your logs. Production logs are visible to your whole team and consume log storage.

lua logs Command

Full reference for the logs command and all filter options

lua test Command

Test tools locally before pushing

Data API

Data API return shapes reference

Troubleshooting

Common errors and solutions