doc-daemon
Skill0 starsChanged 8 months agoMITView on GitHub
Agach daemon agent: onboarding, WebSocket reconnect, Docker builds, chat sessions (Claude CLI), git worktrees, SQLite persistence
- Reads credentials
In this repository10 other files it gives its agents.
- doc-api-routesSkill
- doc-architectureSkill
- doc-business-rulesSkill
- doc-databaseSkill
- doc-dependenciesSkill
- doc-frontendSkill
- doc-identitySkill
- doc-notificationsSkill
- doc-shared-packagesSkill
- doc-testingSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 101
Create SQLite database + migrations
- Distinctive: line 105
Run with reconnect logic
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Agach Daemon (internal/daemon/)
Overview
Background agent that onboards with the server, maintains a WebSocket connection, manages Docker image builds, spawns Claude CLI chat sessions, and manages git worktrees.
Domain Types (domain/)
types.go
OnboardingResult— AccessToken, RefreshToken, NodeID, NodeName, ModeProjectInfo— ID, Name, GitURLDaemonState— StateDisconnected, StateOnboarding, StateConnectedBuildID,BuildStatus— pending, building, success, failedDockerBuild— ID, DockerfileSlug, Version, ImageHash, ImageSize, Status, BuildLog, timestamps
ports.go (interfaces)
ServerAuth— RefreshDaemonToken(nodeID, refreshToken) → accessTokenServerOnboarding— CompleteOnboarding(code, nodeName) → OnboardingResultServerConnection— RunWithReconnect(ctx), Send(msg)ProjectFetcher— GetProject(token, projectID) → ProjectInfoChatUploader— UploadJSONL(token, projectID, featureID, sessionID, filePath)
Configuration (config/config.go)
- File:
~/.config/agach/daemon.yml(or AGACH_SERVER_URL env var) - Fields: base_url, node_name
- Env-only: AGACH_ONBOARDING_CODE (6-digit code)
- Derived: SQLitePath() → daemon.db, WebSocketURL() → ws:// or wss://
App Layer (app/)
Main Loop (app.go)
States: Init → Onboarding → Connected → Reconnecting → Stopped
Run(ctx)— onboard → connect WS → handle events until stopped- WebSocket event routing: docker.list, docker.rebuild, docker.logs, docker.prune, chat.start, chat.user_msg, chat.end, chat.ping
Token Store (tokens.go)
- Persists to
~/.config/agach-daemon/tokens.json(0600 permissions) - Fields: access_token, refresh_token, node_id, node_name
Chat Manager (chat.go)
- Spawns Claude CLI with
--output-format stream-json - Captures stdout/stderr, writes JSONL log
- 30-minute idle TTL with 25-minute warning broadcast
- Stats broadcaster every 5 seconds (token counts, cost, duration)
- Session lifecycle: StartSession → SendMessage → EndSession (stop process, upload JSONL)
ChatSessiontracks: ID, FeatureID, ProjectID, ClaudeSessionID, WorktreePath, token counts, model, message count, timestamps
Docker Service (docker.go)
ListImages(ctx)— groups builds by dockerfile slugRebuild(ctx, slug, eventCh)— creates build record, streams eventsGetBuildLogs(ctx, buildID)— returns build logPruneNonLatest(ctx, eventCh)— removes all but latest per slug
Git Service (git.go)
- Cache dir:
~/.cache/agach EnsureWorktree(projectID, gitURL, mainBranch)— clone or fetch+pull- Auth: SSH keys or GITHUB_TOKEN for HTTPS
Client Layer (client/)
AuthClient— POST /api/daemon/refreshOnboardingClient— POST /api/onboarding/complete (error codes: CODE_NOT_FOUND, CODE_EXPIRED, CODE_ALREADY_USED)ProjectClient— GET /api/projects/{projectID}WSClient— WebSocket with exponential backoff reconnect (1s → 30s max)ChatUploadClient— POST multipart JSONL upload
Inbound WebSocket Hub (inbound/ws/)
- Local hub for TUI clients connecting to the daemon
- Handlers: HandleListDockerfiles, HandleRebuild (async), HandleGetLogs, HandlePrune (async)
- Build/prune events forwarded to hub as they occur
- HandlerFunc signature:
func(ctx, daemonws.Message) (daemonws.Message, error)
Outbound SQLite (outbound/sqlite/)
- Database: daemon.db (local)
buildstable: id, dockerfile_slug, version, image_hash, image_size, status, build_log, timestamps- Repository: Create, FindByID, ListByDockerfile, ListAll, UpdateStatus, Delete, DeleteNonLatest
WebSocket Protocol (pkg/daemonws/)
Docker Messages
docker.list/docker.rebuild/docker.logs/docker.prune- Events:
build.event(slug, build_id, status, log),prune.event(slug, removed, total)
Chat Messages
chat.start→ ChatStartRequest (session_id, feature_id, project_id, node_id, resume_session_id)chat.user_msg→ ChatUserMessage (session_id, content)chat.end→ EndSessionchat.ping→ RefreshActivity- Events:
chat.message,chat.stats,chat.end,chat.error,chat.ttl_warning
Init (init.go)
- Parse
-initflag (create default config) - Load config from file or env
- Create SQLite database + migrations
- Create build repository
- Instantiate daemon app
- Signal handling (SIGINT, SIGTERM)
- Run with reconnect logic
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

