{"id":"autoskill","name":"autoskill","summary":"スクリーンパイプでユーザーの画面を観察し、繰り返される研究ワークフローを検出し、既存の科学エージェントスキルと照合し、まだ扱っていないパターンに対して新しいスキル(または既存のスキルを連鎖させる構成レシピ)を作成してください。","body":"# autoskill\n\n> **Requires a running [screenpipe](https://github.com/screenpipe/screenpipe) daemon.** This skill has no alternate data source — it reads exclusively from the local screenpipe HTTP API (default `http://localhost:3030`). If the daemon isn't running, `run()` raises `ScreenpipeUnreachable` with install instructions.\n\n> **Network access & environment variables.** This skill makes authenticated HTTP requests to (a) the user's local screenpipe daemon on loopback, and (b) the user-configured LLM backend — one of `http://localhost:1234/v1` (LM Studio, default), `https://api.anthropic.com` (opt-in Claude), or a user-supplied BYOK Foundry gateway. The skill reads three environment variables — `SCREENPIPE_TOKEN`, `ANTHROPIC_API_KEY`, `FOUNDRY_API_KEY` — and uses each only to authenticate to the single endpoint its name implies. No other network destinations, no telemetry, no data egress to any third party.\n\n## Overview\n\nTurn the user's own workflow history — captured passively by the local [screenpipe](https://github.com/screenpipe/screenpipe) daemon — into new skills. This skill is on-demand: the user invokes it with a time window, it queries screenpipe's local HTTP API, clusters repeated workflow patterns, compares each pattern against the existing skills in this repo, and produces a staged folder of proposals the user can review, edit, and promote.\n\n## When to Use This Skill\n\nInvoke this skill when the user asks to:\n- \"Analyze my last 4 hours / day / week and propose new skills.\"\n- \"Look at what I've been doing and tell me what's not covered yet.\"\n- \"Draft a skill from my recent workflow.\"\n- \"Find composition recipes for workflows I repeat.\"\n\nDo **not** invoke it for one-off questions about screenpipe itself, for real-time screen queries, or without an explicit user request — the skill analyzes sensitive local content and must stay explicitly user-triggered.\n\n## Privacy Posture\n\n- **Screenpipe handles app/window filtering at capture time.** Install a starter deny-list by copying `references/screenpipe-config.yaml` into the user's screenpipe config. Sensitive apps (password managers, messaging, banking) are never OCR'd in the first place.\n- **Raw OCR never leaves the machine.** `scripts/fetch_window.py` pulls data over localhost HTTP. `scripts/cluster.py` reduces the timeline to app/duration/title summaries. `scripts/redact.py` strips emails, API keys, bearer tokens, and phone numbers as defense-in-depth before any cluster summary reaches the LLM.\n- **LLM backend defaults to `local`.** The recommended setup is [LM Studio](https://lmstudio.ai/) running `Gemma-4-31B-it` — strong reasoning at a size that fits on most workstation GPUs, and no data ever leaves your machine. Cloud backends (`claude`, `foundry`) are opt-in and documented in `config.yaml` for users who explicitly want them. Detection and embeddings always run locally regardless of backend choice.\n- **Dry-run mode** (`--plan`) prints the exact timeline that will be analyzed before any LLM call.\n- **TLS for localhost** (optional, for corporate policy): see `references/https-proxy.md` for the Caddy pattern.\n\n## Prerequisites\n\n### 1. Screenpipe daemon\n\nEither install the official release or build from source. Either way the daemon binds HTTP on `localhost:3030` by default.\n\n**From source** (recommended if you want the CLI daemon without the desktop GUI):\n\n```bash\ngit clone --depth 1 https://github.com/mediar-ai/screenpipe.git\ncd screenpipe\ncargo build -p screenpipe-engine --release\n# System deps (macOS): cmake + full Xcode.app (not just Command Line Tools).\n#   brew install cmake\n#   # if xcodebuild plug-ins error: sudo xcodebuild -runFirstLaunch\n./target/release/screenpipe doctor   # confirm permissions + ffmpeg\n./target/release/screenpipe record --disable-audio --use-pii-removal\n```\n\nFirst run will prompt for macOS Screen Recording permission. Grant it and relaunch.\n\n### 2. Screenpipe API token\n\nThe local API now requires bearer auth. Retrieve your token and export it:\n\n```bash\nexport SCREENPIPE_TOKEN=$(screenpipe auth token)\n```\n\n(Or set `screenpipe.token` directly in `config.yaml` — env var is preferred since it keeps secrets out of version control.)\n\n### 3. Python environment\n\nVia `pipenv` from the repo root:\n\n```bash\npipenv install httpx pyyaml sentence-transformers\n```\n\nThe embedding model (`sentence-transformers/all-MiniLM-L6-v2`, ~80 MB) downloads on first run.\n\n### 4. Local LLM (default path) — LM Studio\n\n- Install [LM Studio](https://lmstudio.ai/).\n- Download `Gemma-4-31B-it` (or another strong reasoning model; adjust `local.model` in `config.yaml`).\n- Load it via the CLI for headless use (no GUI required):\n\n```bash\nlms load gemma-4-31b-it --context-length 131072 --gpu max -y\nlms status   # confirm server running on :1234\n```\n\n### 5. Cloud LLM backends (optional, opt-in)\n\nOnly if you explicitly opt out of local:\n- `claude`: set `ANTHROPIC_API_KEY`, flip `backend: claude` in `config.yaml`.\n- `foundry`: set `FOUNDRY_API_KEY`, flip `backend: foundry`, set `foundry.endpoint` to your corporate gateway URL.\n\n## Architecture\n\n```\nscreenpipe daemon (user-installed)\n        │  HTTP on localhost:3030\n        ▼\nscripts/fetch_window.py    → normalized timeline events\nscripts/redact.py          → regex scrub (defense-in-depth)\nscripts/cluster.py         → sessions + clusters (local only)\nscripts/match_skills.py    → top-k vs existing 135 skills (local embeddings)\nscripts/synthesize.py      → LLM judge: reuse / compose / novel\n        │\n        ▼\n~/.autoskill/proposed/<timestamp>/        (default; override with --out)\n  ├── report.md\n  ├── composition-recipes/<name>/SKILL.md\n  └── new-skills/<name>/SKILL.md\n\nscripts/promote.py         → user-approved proposal → skills/<name>/\n```\n\n## Workflow\n\nThe skill ships a unified CLI at `scripts/autoskill.py` with three subcommands:\n\n```bash\npython scripts/autoskill.py doctor   --config config.yaml --skills-dir ../\npython scripts/autoskill.py run      --start ... --end ... --config config.yaml\npython scripts/autoskill.py promote  --proposed ~/.autoskill/proposed/<ts> --skills-dir ../ --name <skill>\n```\n\n### 0. Preflight with `doctor`\n\nBefore a full run, verify every dependency in one shot:\n\n```bash\npython scripts/autoskill.py doctor \\\n  --config skills/autoskill/config.yaml \\\n  --skills-dir skills\n```\n\nThe report covers `config` (backend choice valid), `skills_dir` (exists), `screenpipe` (reachable + authed), and `llm` (LM Studio serving or API key present). Non-zero exit on any failure, with the offending line marked `error`.\n\n### 1. Run the pipeline\n\n```bash\nexport SCREENPIPE_TOKEN=$(screenpipe auth token)\npython scripts/autoskill.py run \\\n  --start \"2026-04-17T00:00:00Z\" \\\n  --end   \"2026-04-17T23:59:59Z\" \\\n  --config skills/autoskill/config.yaml \\\n  --skills-dir skills\n```\n\nProposals land in `~/.autoskill/proposed/<timestamp>/` by default, keeping experimental output out of the skills repo. Pass `--out PATH` to override.\n\nInternally:\n1. **Fetch** — `fetch_window` paginates screenpipe's `/search` endpoint, normalizes events to `{ts, app, window_title, text, content_type}`.\n2. **Redact** — `redact` scrubs emails, API keys, bearer tokens, phones from OCR text and window titles as defense-in-depth over screenpipe's own PII removal.\n3. **Cluster** — `segment_sessions` splits on idle gaps (default 10 min) and drops short sessions; `cluster_sessions` groups sessions by app-signature and keeps clusters of size `min_cluster_size` (default 2).\n4. **Match** — `load_skill_descriptions` reads frontmatter from every `SKILL.md` in `skills/`; `top_k_matches` ranks each cluster against all skills using local `sentence-transformers` embeddings (cosine similarity).\n5. **Synthesize** — `synthesize` prompts the configured LLM backend to classify each cluster as `reuse`, `compose`, or `novel` and emit a SKILL.md body where appropriate.\n6. **Report** — writes `<out_dir>/<ts>/report.md`, plus `new-skills/<name>/SKILL.md` or `composition-recipes/<name>/SKILL.md` for each proposal.\n\nAdd `--dry-run` to stop after clustering; this skips the LLM (and the sentence-transformers load), writing only `plan.md` for inspection.\n\n### 2. Review and promote\n\nOpen `~/.autoskill/proposed/<ts>/report.md`, edit drafts in place, delete anything you don't want. Then:\n\n```bash\npython scripts/autoskill.py promote \\\n  --proposed ~/.autoskill/proposed/2026-04-17T14-30-00 \\\n  --skills-dir skills \\\n  --name zotero-pubmed-helper\n```\n\n`promote` moves the directory into `skills/<name>/`, refusing to overwrite an existing skill. Exits non-zero with a friendly error if the proposal isn't found or the target already exists.\n\n## Configuration\n\nSee `config.yaml` for the full shape. Default values (local-first):\n\n```yaml\nbackend: local\nlocal:\n  endpoint: http://localhost:1234/v1   # LM Studio's Developer server\n  model: Gemma-4-31B-it\n\nscreenpipe:\n  url: http://localhost:3030           # or https://screenpipe.local via Caddy\n\ncluster:\n  min_session_minutes: 5\n  idle_gap_minutes: 10\n  min_cluster_size: 2\n```\n\nTo opt into a cloud backend:\n\n```yaml\nbackend: claude                         # or foundry\nclaude:\n  model: claude-opus-4-7\n```\n\n## Composition recipes vs new skills\n\n- **compose**: the LLM judged that chaining existing skills covers the workflow. The emitted SKILL.md is intentionally thin — frontmatter + a \"Workflow\" section that invokes existing skills in order. The same agent runtime that discovered the skill can then invoke it end-to-end.\n- **novel**: no combination of existing skills covers it. A fuller SKILL.md is drafted, still following repo conventions (frontmatter, Overview, When to Use, Workflow). The user should always review new-skill drafts before promoting.\n\n## Testing\n\nThe skill is covered by a small pytest suite at `tests/autoskill/` in the repository root. Each script is unit-tested in isolation with dependency injection (mock HTTP transport, stub backend, stub embedder):\n\n```bash\npython -m pytest tests/autoskill -v\n```\n\n## Composition with other skills in this repo\n\nThe autoskill's embedding index covers all 135 sibling skills. Workflows that look like scientific writing will match `scientific-writing` / `literature-review` / `citation-management`; figure work will match `scientific-schematics` / `generate-image` / `infographics`; slide prep matches `scientific-slides` / `pptx`; etc. When a cluster scores high against two or three sibling skills the emitted composition recipe names them explicitly, so the user's future agent invocations use the optimized paths already documented in this repo.","author":"@K-Dense-AI","ownerProfile":null,"authorContacts":null,"sourceUrl":"https://github.com/K-Dense-AI/scientific-agent-skills/tree/main/skills/autoskill","license":"MIT","category":"review","lang":"en","tokens":2599,"stars":0,"calls30d":1,"claimed":false,"visibility":"public","origin":"crawler","version":"0.1.0","createdAt":"2026-08-22","updatedAt":"2026-08-22","files":[{"path":"config.yaml","size":2030,"sha256":"d6465c8286d05ed11edc45a74cb2cc035305667d913a3f8992d96f0c277eb924"},{"path":".gitignore","size":34,"sha256":"6f4ff2992c4e2558837e2e09c39ed2bba140658755b22d046aab810ea2c90ca0"},{"path":"references/https-proxy.md","size":1518,"sha256":"ac48c686ea0f79986787bb3bce66c10a5ab31e8c90d1e59f9e8c89930eaadd73"},{"path":"references/screenpipe-config.yaml","size":1567,"sha256":"273bf6e93e89508f6f73222ef7afb09d4d12e7f979a5958d959ac4a666f78fc4"},{"path":"scripts/autoskill.py","size":1158,"sha256":"324c7fec82fcffa73f61f2646e9b47b3500b1788abd22dbc48e99247baa23e44"},{"path":"scripts/backends.py","size":3936,"sha256":"912f4cb41402e6b12d28dd81d847677d3720892d4452280beec8329b6cda05f8"},{"path":"scripts/cluster.py","size":1723,"sha256":"64197a28649734e72ab3f2430afe092595f2214bbc0b4087aac415f2fe2b8024"},{"path":"scripts/doctor.py","size":3501,"sha256":"1c450c00cdd5aeca5b1f8995710a584987747a094da58aafed5a6c57262461b2"},{"path":"scripts/fetch_window.py","size":1172,"sha256":"6a0501d36e82665fe728a37ae49017fb9584703fd9f2fa6871f3921f559ca0ef"},{"path":"scripts/match_skills.py","size":1316,"sha256":"f8f36a013d570adfcbdeeefca4612cbce25127ed4a2d1426ec478eb600c988dd"},{"path":"scripts/promote.py","size":1559,"sha256":"aa975bfbdc7c64c1989445627382bd4f7dfd79ab289d75d2997de67ad8ce7ba7"},{"path":"scripts/redact.py","size":1634,"sha256":"660e728af1de713399d7e91311a43ab5e6b7ba3e90a6ac97a177468f3df2d140"},{"path":"scripts/run.py","size":7370,"sha256":"7c16e2a5ddf4aeac52a143d54bfa16b5b4a6f9e897c296ae3f1092cd0dcaff46"},{"path":"scripts/synthesize.py","size":2378,"sha256":"7bea2dc611241fd8be338fb84ae956296f449b59e2d5a15fae7bc76248505eb0"}],"requires":{"mcp":[],"tools":["Read Write Edit Bash"]},"safety":{"flags":[{"code":"net.endpoints","kind":"exfiltration","excerpt":"api.anthropic.com, caddyserver.com, foundry.example.com, lmstudio.ai, screenpipe.local","message":"bundled scripts reach 5 external host(s)","severity":"warn"}],"scannedAt":"2026-08-22","hasScripts":true,"networkEndpoints":["api.anthropic.com","caddyserver.com","foundry.example.com","lmstudio.ai","screenpipe.local"]}}