1k debug logging

From OneKeyHQ/app-monorepo · View interactive version

1k debug logging is an AI agent skill from the GitHub repository OneKeyHQ/app-monorepo. Add or clean temporary OneKey debug console logs with consistent prefixes and safe stringify. Excludes analytics and permanent server logs.

How to use this skill

Skill file

OneKey Debug Logging

Use this skill for temporary local debug logs. Keep the convention to one filterable prefix and one safe stringify helper.

Pattern

Create one local helper near the debug area. Rename the prefix and exported helper for the domain:

const LOG_PREFIX = '[MKT-TAB]';

function stringifyLogValue(value: unknown) {
  try {
    return JSON.stringify(value);
  } catch (error) {
    return JSON.stringify({
      stringifyError: error instanceof Error ? error.message : String(error),
    });
  }
}

export function debugMarketTabsLog(label: string, value?: unknown) {
  if (process.env.NODE_ENV === 'production') {
    return;
  }

  const valueText = value === undefined ? '' : ` ${stringifyLogValue(value)}`;
  // eslint-disable-next-line no-console
  console.log(`${LOG_PREFIX} ${label}${valueText}`);
}

Use the helper at call sites instead of raw console.log:

debugMarketTabsLog('tab-change', {
  activeTab,
  itemCount: items.length,
});

Rules

Related Skills

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.