---
name: kimaki-debug
description: Debug and administer Kimaki itself. Use when sessions do not respond, the bot shows errors, you need the Kimaki or OpenCode service logs, want to profile the bot, restart it (only when asked), connect a model provider with `kimaki login`, check who may use the bot, or file a Kimaki bug report. ALWAYS load when Kimaki misbehaves or before filing a Kimaki issue. Only for Kimaki Discord sessions.
title: kimaki-debug
canonical_url: https://skilld.dev/gh/remorses/kimaki/kimaki-debug
last_updated: 2026-10-30T13:11:14.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> If the user asked to install this Skill, run `npx skilld install remorses/kimaki/kimaki-debug`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/kimaki-debug`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/remorses/kimaki/kimaki-debug) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/kimaki-debug`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/kimaki-debug --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/kimaki-debug --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Debugging Kimaki

Read the logs before guessing. Do not restart the bot (`kimaki restart`) unless the user explicitly asks.

## Kimaki bot log

`$KIMAKI_DATA_DIR/kimaki.log` holds only the current bot run. The run before the last restart (with the crash that caused it) is in `kimaki.previous.log`. Lines are `<ISO time> <LEVEL> [<MODULE>] <message>` and errors include their cause chain. It logs incoming messages, run start/finish/failure per thread and session, Discord and OpenCode errors, routines and crashes.

```bash
tail -n 200 $KIMAKI_DATA_DIR/kimaki.log
grep -E ' (WARN|ERROR) ' $KIMAKI_DATA_DIR/kimaki.log | tail -n 50
grep '<thread_id or ses_id>' $KIMAKI_DATA_DIR/kimaki.log
```

## OpenCode service log

The shared `opencode serve --service` daemon appends to `~/.local/share/opencode/log/opencode.log` (`$XDG_DATA_HOME/opencode/log`; `opencode debug paths` prints the folder). The file is never reset and can be very large: use `tail` or `grep`, never read it whole. Lines are logfmt. `run=<id>` is one daemon process, so filter by the run of the last line. The daemon pid and URL are in `~/.local/state/opencode/service.json`.

```bash
LOG=~/.local/share/opencode/log/opencode.log
RUN=$(tail -n 1 $LOG | grep -o 'run=[a-z0-9]*')
grep "$RUN " $LOG | grep -E '^timestamp=[^ ]+ level=(ERROR|WARN)' | tail -n 50
grep "$RUN " $LOG | grep '<ses_id>' | tail -n 100
```

## Other tools

- `kimaki session events <id>` prints the recorded OpenCode events of a thread as JSONL.
- `kimaki restart` restarts the bot (only when asked). Sessions keep running in OpenCode.
- `kimaki profile cpu --duration 30s` and `kimaki profile heap` print the profile file path.
- `kimaki login PROVIDER` lists login methods of a provider. `--key` connects an API key, `--method` starts OAuth, `--attempt` checks or completes an attempt. Credentials belong to OpenCode.

## Who can use the bot

Only users with one of these Discord permissions can message the bot: Server Owner, Administrator, Manage Server, or the "Kimaki" role (case-insensitive). Other Discord bots are ignored; assign a bot the "Kimaki" role to let it trigger sessions (multi-agent orchestration).

## Reporting a bug

ALWAYS read https://kimaki.dev/docs/guides/report-bugs first. That page is the source of truth for exporting session JSONL, sharing evidence in a gist and filing bugs. Never open a pull request on remorses/kimaki unless remorses asked for one in a comment on the issue.
