アーリーアクセス招待制です。SDK はまだ公開されていません。招待をリクエスト
本文へスキップ
ドキュメント

AI エージェントと使う

Claude Code、Cursor などのコーディングエージェントにこのドキュメントを渡し、プロジェクトに Lyrelog を組み込むプロンプトを使います。

このドキュメントのどのページもプレーンな Markdown として読めます。そのため、コーディングエージェントは記憶に頼って推測する代わりにドキュメントを読めます。Lyrelog のような新しいサービスについては、記憶に頼るとたいてい間違えます。

エージェント向けのファイル

アドレス内容
/llms.txtすべてのページとその説明の一覧で、各ページの Markdown にリンクしています。エージェントが探す llms.txt 形式です。
/llms-full.txt全ページを 1 つにまとめたファイル。ドキュメント全体を一度にエージェントのコンテキストに入れられます。
/<page>.md1 ページ分。例:/sdks/go.md

各ページのタイトルの下には Copy Markdown と、ページを ChatGPT、Claude、Cursor に送る Open もあります。

プロジェクトに Lyrelog を組み込むプロンプト

lyr_ing_... を自分のインジェストキーに置き換えて、エージェントに貼り付けてください(キーはプロジェクトの API keys ページにあります。キー を参照。書き込み専用なので、アプリに組み込んで配布しても安全です)。キーをリポジトリに入れたくない場合は、環境変数に入れて、その名前をエージェントに伝えてください。

Add Lyrelog logging to this project. Read https://docs.lyrelog.com/llms.txt first, then the
page of the SDK for this project's language (or the HTTP API page if there's no SDK for it).
Don't rely on what you remember about Lyrelog: follow the docs.

1. Install the SDK and start it once, where the app or service starts, with the ingest key
   lyr_ing_... (or from the environment variable LYRELOG_KEY). Keep the default endpoint.
2. Make sure queued events are sent before the process ends: flush or close the client as the
   SDK page says for this kind of program (server, CLI, serverless function, app).
3. Capture errors: unhandled ones the way the SDK page shows, and the places in this code that
   catch an error and carry on.
4. Log a few events where something happens to a person: sign in, a payment, a sync, a failed
   request. Use a stable snake_case name as the message (payment_declined), a level, an area
   (category) and attributes with the details to filter by.
5. Identify the person with our own user id (setUser or the SDK's equivalent), never an email
   address, and clear it on sign-out.
6. Never put passwords, tokens, keys, cookies, full request bodies or personal data in messages,
   attributes or payloads.
7. Tell me which environment the events will arrive under, so I can pick it in the dashboard.

SDK はまだ公開されていないため、今はエージェントが SDK をインストールすることはできません。このプロンプトは SDK の公開後に使えるようになります。それまでは、エージェントは HTTP API でイベントを送れます。

エージェントにイベントを読ませる

コマンドラインツール を使うと、コーディングエージェントがあなたとしてサインインした状態で、イベントを検索し、エラーを読み、セッションを通して 1 人のユーザーを追えます。エージェントが実行すると JSON で出力します。サインインは lyrelog login で一度だけあなたが行います。エージェントが自分でサインインすることはできません。エラーを調査させるプロンプトも含めて、エージェントとスクリプト向け を参照してください。

ヒント

  • ページを指定する。 「Read https://docs.lyrelog.com/sdks/python.md and add Lyrelog to the FastAPI app」のように指示すると、検索させるよりも速く、正確です。
  • テストイベントを頼む。 アプリの起動時にイベントを 1 つ記録させ、実行して、届くことを確かめさせてください(クイックスタート を参照)。キーや環境の間違いに気づく一番の近道です。
  • 記録する内容を見直す。 エージェントはログを多く出しすぎる傾向があります。起きたこと 1 つにつきイベント 1 つ、名前は固定、という形のほうが、関数呼び出しごとに 1 行出すよりも検索しやすく、グラフにしやすく、料金も抑えられます。