@ogkranthi/agentshift 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/.github/CODEOWNERS +25 -0
  2. package/.github/ISSUE_TEMPLATE/bug_report.yml +93 -0
  3. package/.github/ISSUE_TEMPLATE/config.yml +5 -0
  4. package/.github/ISSUE_TEMPLATE/feature_request.yml +54 -0
  5. package/.github/ISSUE_TEMPLATE/platform_request.yml +55 -0
  6. package/.github/PULL_REQUEST_TEMPLATE.md +53 -0
  7. package/.github/SETUP.md +65 -0
  8. package/.github/workflows/ci.yml +85 -0
  9. package/AGENTS.md +68 -0
  10. package/BACKLOG.md +55 -0
  11. package/CODE_OF_CONDUCT.md +43 -0
  12. package/CONTRIBUTING.md +136 -0
  13. package/LICENSE +201 -0
  14. package/README.md +112 -0
  15. package/SECURITY.md +42 -0
  16. package/bin/agentshift.js +4 -0
  17. package/examples/pregnancy-companion/AGENTS.md +212 -0
  18. package/examples/pregnancy-companion/BOOTSTRAP.md +55 -0
  19. package/examples/pregnancy-companion/SKILL.md +88 -0
  20. package/examples/pregnancy-companion/data/appointments.md +5 -0
  21. package/examples/pregnancy-companion/data/questions-for-doctor.md +7 -0
  22. package/examples/pregnancy-companion/data/symptoms-log.md +5 -0
  23. package/examples/pregnancy-companion/data/weight-log.md +6 -0
  24. package/examples/pregnancy-companion/knowledge/appointments.md +122 -0
  25. package/examples/pregnancy-companion/knowledge/exercise.md +114 -0
  26. package/examples/pregnancy-companion/knowledge/nutrition.md +112 -0
  27. package/examples/pregnancy-companion/knowledge/warning-signs.md +80 -0
  28. package/examples/pregnancy-companion/knowledge/week-by-week.md +198 -0
  29. package/index.js +4 -0
  30. package/package.json +18 -0
  31. package/pyproject.toml +72 -0
  32. package/specs/claude-code-format.md +397 -0
  33. package/specs/ir-schema.json +438 -0
  34. package/specs/ir-schema.md +370 -0
  35. package/specs/openclaw-skill-format.md +483 -0
  36. package/src/agentshift/__init__.py +3 -0
  37. package/src/agentshift/cli.py +44 -0
  38. package/src/agentshift/emitters/__init__.py +1 -0
  39. package/src/agentshift/ir.py +134 -0
  40. package/src/agentshift/parsers/__init__.py +1 -0
  41. package/tests/__init__.py +0 -0
  42. package/tests/fixtures/pregnancy-companion/AGENTS.md +212 -0
  43. package/tests/fixtures/pregnancy-companion/BOOTSTRAP.md +55 -0
  44. package/tests/fixtures/pregnancy-companion/SKILL.md +88 -0
  45. package/tests/fixtures/pregnancy-companion/data/appointments.md +5 -0
  46. package/tests/fixtures/pregnancy-companion/data/questions-for-doctor.md +7 -0
  47. package/tests/fixtures/pregnancy-companion/data/symptoms-log.md +5 -0
  48. package/tests/fixtures/pregnancy-companion/data/weight-log.md +6 -0
  49. package/tests/fixtures/pregnancy-companion/knowledge/appointments.md +122 -0
  50. package/tests/fixtures/pregnancy-companion/knowledge/exercise.md +114 -0
  51. package/tests/fixtures/pregnancy-companion/knowledge/nutrition.md +112 -0
  52. package/tests/fixtures/pregnancy-companion/knowledge/warning-signs.md +80 -0
  53. package/tests/fixtures/pregnancy-companion/knowledge/week-by-week.md +198 -0
@@ -0,0 +1,397 @@
1
+ # Claude Code Agent Format Spec
2
+
3
+ **Status:** Canonical
4
+ **Source:** Observed from `~/.claude/settings.json`, live Claude Code installation, and OpenClaw skill-creator SKILL.md spec.
5
+
6
+ ---
7
+
8
+ ## Overview
9
+
10
+ Claude Code represents agents through a combination of files:
11
+
12
+ | File | Purpose |
13
+ |------|---------|
14
+ | `CLAUDE.md` | Project context and conventions — injected into every session |
15
+ | `~/.claude/settings.json` | Global permissions, allowed tools, additional directories |
16
+ | `~/.claude/settings.local.json` | Local overrides (not committed to git) |
17
+ | `SKILL.md` | Skill definition (same format as OpenClaw, used by Claude Code skill system) |
18
+
19
+ ---
20
+
21
+ ## CLAUDE.md
22
+
23
+ ### Purpose
24
+
25
+ `CLAUDE.md` is a free-form Markdown file that Claude Code reads at session start. It provides project-level context and conventions. It is **not** a system prompt override — it supplements Claude's built-in behavior.
26
+
27
+ Claude Code looks for `CLAUDE.md` files in:
28
+ 1. The current working directory
29
+ 2. Parent directories (up to the repo root)
30
+ 3. `~/.claude/CLAUDE.md` (global, always loaded)
31
+
32
+ Multiple `CLAUDE.md` files are merged. More-specific files (deeper in the directory tree) take precedence.
33
+
34
+ ### Format
35
+
36
+ Pure Markdown. No frontmatter. No required sections.
37
+
38
+ ```markdown
39
+ # Project Name
40
+
41
+ Short description of what this project is.
42
+
43
+ ## Tech Stack
44
+ - **Language**: TypeScript
45
+ - **Framework**: React + Vite
46
+ - **Backend**: Vercel serverless functions
47
+
48
+ ## Project Structure
49
+ - `src/` — React frontend
50
+ - `api/` — Vercel serverless functions
51
+ - `scripts/` — Build and automation scripts
52
+
53
+ ## Commands
54
+ - `npm run dev` — Start dev server
55
+ - `npm run build` — Production build
56
+ - `npm test` — Run tests
57
+
58
+ ## Key Design Decisions
59
+ - `verbatimModuleSyntax` is enabled — always use `import type` for type-only imports
60
+ - All styles in `src/App.css` using CSS custom properties
61
+ ```
62
+
63
+ ### Observed Conventions
64
+
65
+ | Section | Description |
66
+ |---------|-------------|
67
+ | `## Tech Stack` | Languages, frameworks, key packages |
68
+ | `## Project Structure` | Directory layout with one-line descriptions |
69
+ | `## Commands` | Essential CLI commands for the project |
70
+ | `## Key Design Decisions` | Non-obvious conventions Claude must respect |
71
+ | `## Architecture` | High-level system design |
72
+ | `## API` | Endpoint listing if relevant |
73
+ | `## Testing` | Test strategy and commands |
74
+
75
+ There is no enforced schema. Claude Code reads the full content as context.
76
+
77
+ ### Global CLAUDE.md (`~/.claude/CLAUDE.md`)
78
+
79
+ Loaded in every session regardless of working directory. Use for:
80
+ - Personal preferences that apply to all projects
81
+ - Default tools and behaviors
82
+ - Cross-project conventions
83
+
84
+ ---
85
+
86
+ ## settings.json Schema
87
+
88
+ Located at `~/.claude/settings.json`. Controls global Claude Code behavior.
89
+
90
+ ### Top-Level Structure
91
+
92
+ ```json
93
+ {
94
+ "permissions": { ... },
95
+ "additionalDirectories": [ ... ],
96
+ "model": "claude-opus-4-5",
97
+ "theme": "dark"
98
+ }
99
+ ```
100
+
101
+ ### `permissions` Object
102
+
103
+ The permissions object controls which tools Claude Code can use and under what conditions.
104
+
105
+ ```json
106
+ {
107
+ "permissions": {
108
+ "allow": [
109
+ "Bash(npm run build)",
110
+ "Bash(git commit:*)",
111
+ "Bash(gh pr:*)",
112
+ "WebSearch",
113
+ "WebFetch(domain:docs.anthropic.com)",
114
+ "Read(/Users/alice/**)"
115
+ ],
116
+ "deny": [
117
+ "Bash(rm -rf:*)",
118
+ "Bash(git push --force:*)"
119
+ ]
120
+ }
121
+ }
122
+ ```
123
+
124
+ #### Permission Rule Syntax
125
+
126
+ Rules follow the pattern `ToolName(argument_pattern)`:
127
+
128
+ | Pattern | Example | Meaning |
129
+ |---------|---------|---------|
130
+ | `ToolName` | `WebSearch` | Allow/deny this tool for all inputs |
131
+ | `ToolName(literal)` | `Bash(npm run build)` | Exact command match |
132
+ | `ToolName(prefix:*)` | `Bash(git commit:*)` | Any command starting with `git commit` |
133
+ | `ToolName(domain:host)` | `WebFetch(domain:github.com)` | Specific domain for WebFetch |
134
+ | `Read(path/**)`| `Read(/Users/alice/**)` | Path glob for Read tool |
135
+
136
+ #### Built-in Tools Available in Claude Code
137
+
138
+ | Tool | Description |
139
+ |------|-------------|
140
+ | `Bash` | Run shell commands |
141
+ | `Read` | Read file contents |
142
+ | `Write` | Write/overwrite files |
143
+ | `Edit` | Targeted string replacement in files |
144
+ | `Glob` | File pattern matching |
145
+ | `Grep` | Content search (ripgrep-based) |
146
+ | `WebSearch` | Web search |
147
+ | `WebFetch` | Fetch a URL |
148
+ | `TodoWrite` | Manage task lists |
149
+ | `Agent` | Spawn subagents |
150
+ | `NotebookEdit` | Edit Jupyter notebooks |
151
+
152
+ ### `additionalDirectories`
153
+
154
+ Directories outside the working directory that Claude Code can read:
155
+
156
+ ```json
157
+ {
158
+ "additionalDirectories": [
159
+ "/Users/alice/.openclaw",
160
+ "/tmp",
161
+ "/private/tmp",
162
+ "/Users/alice/shared-libs"
163
+ ]
164
+ }
165
+ ```
166
+
167
+ ### `settings.local.json`
168
+
169
+ Same schema as `settings.json`. Loaded after `settings.json` and merged. Intended for machine-local overrides not committed to source control.
170
+
171
+ ---
172
+
173
+ ## SKILL.md in Claude Code
174
+
175
+ Claude Code uses the same `SKILL.md` format as OpenClaw for its skill system. The format is identical — see `specs/openclaw-skill-format.md` for the full spec.
176
+
177
+ ### YAML Frontmatter
178
+
179
+ ```yaml
180
+ ---
181
+ name: my-skill
182
+ description: "What this skill does. Use when: ... NOT for: ..."
183
+ ---
184
+ ```
185
+
186
+ Only `name` and `description` are supported in Claude Code SKILL.md frontmatter. The `metadata.openclaw` extensions (`emoji`, `requires`, `install`) are OpenClaw-specific and ignored by Claude Code.
187
+
188
+ ### Body
189
+
190
+ Full Markdown instructions. Same progressive disclosure pattern as OpenClaw skills — the body is loaded only after the skill triggers.
191
+
192
+ ### Skill Directory
193
+
194
+ Claude Code skills live in `~/.claude/skills/<skill-name>/SKILL.md` or alongside the project.
195
+
196
+ The supporting files (`AGENTS.md`, `SOUL.md`, `USER.md`, etc.) are OpenClaw conventions and are not part of the Claude Code skill system directly. However, Claude Code will read them if referenced in `CLAUDE.md` or `SKILL.md`.
197
+
198
+ ---
199
+
200
+ ## Expressing Agent Capabilities in Claude Code
201
+
202
+ ### Tools / Capabilities
203
+
204
+ Tools are expressed through `settings.json` permissions (which tools are allowed) and `CLAUDE.md`/`SKILL.md` instructions (how to use them):
205
+
206
+ **settings.json** — grant access:
207
+ ```json
208
+ {
209
+ "permissions": {
210
+ "allow": [
211
+ "Bash(gh:*)",
212
+ "WebFetch(domain:api.github.com)"
213
+ ]
214
+ }
215
+ }
216
+ ```
217
+
218
+ **SKILL.md body** — instruct usage:
219
+ ```markdown
220
+ ## GitHub Operations
221
+
222
+ Use the `gh` CLI for all GitHub interactions:
223
+
224
+ ```bash
225
+ gh pr list --repo owner/repo
226
+ gh issue create --title "Bug" --body "Details"
227
+ ```
228
+ ```
229
+
230
+ ### Knowledge Sources
231
+
232
+ Referenced by path in `CLAUDE.md` or `SKILL.md`. The agent uses the `Read` tool to load them:
233
+
234
+ ```markdown
235
+ ## Reference Files
236
+
237
+ - `docs/api-schema.json` — Full API schema
238
+ - `docs/conventions.md` — Coding conventions
239
+ ```
240
+
241
+ ### Triggers (Cron)
242
+
243
+ Claude Code has no built-in cron scheduler. Triggers are implemented externally:
244
+
245
+ 1. **System cron** + `claude --print` CLI:
246
+ ```cron
247
+ 0 9 * * * cd /path/to/project && claude --print --permission-mode bypassPermissions "Run the daily report"
248
+ ```
249
+
250
+ 2. **OpenClaw cron** targeting a Claude Code session (via `coding-agent` skill):
251
+ ```json
252
+ {
253
+ "payload": {
254
+ "kind": "agentTurn",
255
+ "message": "cd ~/project && claude --permission-mode bypassPermissions --print 'Check for new issues and triage them'"
256
+ }
257
+ }
258
+ ```
259
+
260
+ 3. **GitHub Actions** / CI scheduling for project-level automation.
261
+
262
+ ---
263
+
264
+ ## Project-Level `.claude/` Directory
265
+
266
+ A project can include a `.claude/` directory for project-scoped configuration:
267
+
268
+ ```
269
+ project/
270
+ └── .claude/
271
+ ├── settings.json # Project-scoped permissions (committed to git)
272
+ └── settings.local.json # Local overrides (gitignored)
273
+ ```
274
+
275
+ Project-level `settings.json` is merged with the global `~/.claude/settings.json`. Project settings take precedence.
276
+
277
+ ---
278
+
279
+ ## Skill Triggering
280
+
281
+ Claude Code routes to skills based on the `description` field in `SKILL.md` frontmatter. The routing is semantic — Claude reads the description and decides whether to load the skill body.
282
+
283
+ Best practice (same as OpenClaw):
284
+
285
+ ```yaml
286
+ description: "GitHub operations via `gh` CLI. Use when: (1) checking PR status, (2) creating issues, (3) viewing CI runs. NOT for: local git operations, non-GitHub repos."
287
+ ```
288
+
289
+ ---
290
+
291
+ ## Complete Example — Single-File Agent
292
+
293
+ A minimal Claude Code agent is just a `CLAUDE.md`:
294
+
295
+ ```markdown
296
+ # My Project Agent
297
+
298
+ This agent helps with Python data analysis projects.
299
+
300
+ ## Tech Stack
301
+ - Python 3.11+
302
+ - pandas, numpy, matplotlib
303
+ - Jupyter notebooks in `notebooks/`
304
+
305
+ ## Conventions
306
+ - All data files in `data/raw/` (never modify these)
307
+ - Processed data in `data/processed/`
308
+ - Outputs in `outputs/`
309
+
310
+ ## Commands
311
+ - `pytest tests/` — Run tests
312
+ - `jupyter lab` — Start notebook server
313
+ - `python scripts/process_data.py` — Run pipeline
314
+
315
+ ## Key Rules
316
+ - Never write to `data/raw/` — read only
317
+ - Always document new functions with docstrings
318
+ - Run tests before committing
319
+ ```
320
+
321
+ With `settings.json`:
322
+
323
+ ```json
324
+ {
325
+ "permissions": {
326
+ "allow": [
327
+ "Bash(pytest:*)",
328
+ "Bash(python:*)",
329
+ "Bash(jupyter:*)",
330
+ "WebSearch"
331
+ ]
332
+ },
333
+ "additionalDirectories": ["/Users/alice/datasets"]
334
+ }
335
+ ```
336
+
337
+ ---
338
+
339
+ ## Complete Example — Skill-Based Agent
340
+
341
+ A more structured agent with `SKILL.md`:
342
+
343
+ **`~/.claude/skills/github-reviewer/SKILL.md`:**
344
+
345
+ ```yaml
346
+ ---
347
+ name: github-reviewer
348
+ description: "Automated GitHub PR review agent. Use when: reviewing pull requests, checking CI status, creating review comments. NOT for: local git operations, non-GitHub work."
349
+ ---
350
+
351
+ # GitHub PR Reviewer
352
+
353
+ ## Workflow
354
+
355
+ 1. List open PRs: `gh pr list --repo owner/repo --state open`
356
+ 2. Review changed files: `gh pr diff <number>`
357
+ 3. Check CI: `gh pr checks <number>`
358
+ 4. Post review: `gh pr review <number> --comment -b "Review notes"`
359
+
360
+ ## Review Checklist
361
+
362
+ - Tests added or updated?
363
+ - No obvious security issues (SQL injection, XSS, secrets in code)?
364
+ - PR description is clear?
365
+ - Breaking changes documented?
366
+
367
+ ## Commands
368
+
369
+ ```bash
370
+ # Full PR review context
371
+ gh pr view <number> --json title,body,author,additions,deletions,changedFiles
372
+
373
+ # Post approval
374
+ gh pr review <number> --approve
375
+
376
+ # Request changes
377
+ gh pr review <number> --request-changes -b "Please address the issues above"
378
+ ```
379
+ ```
380
+
381
+ ---
382
+
383
+ ## Mapping: Claude Code vs OpenClaw
384
+
385
+ | Concept | Claude Code | OpenClaw |
386
+ |---------|-------------|----------|
387
+ | Agent instructions | `CLAUDE.md` + `SKILL.md` body | `SKILL.md` body |
388
+ | Skill trigger | `description` in `SKILL.md` | `description` in `SKILL.md` |
389
+ | Tool permissions | `settings.json` `permissions.allow` | `metadata.openclaw.requires` |
390
+ | Knowledge files | `Read` tool + paths in `CLAUDE.md` | `knowledge/` dir + paths in SKILL.md |
391
+ | Cron triggers | External (system cron, GH Actions) | `~/.openclaw/cron/jobs.json` |
392
+ | Agent identity | `CLAUDE.md` prose | `SOUL.md` + `IDENTITY.md` |
393
+ | User profile | `CLAUDE.md` or `~/.claude/CLAUDE.md` | `USER.md` |
394
+ | Heartbeat | Not natively supported | `HEARTBEAT.md` + cron job |
395
+ | Install steps | Not expressed | `metadata.openclaw.install` |
396
+ | Multi-file workspace | `additionalDirectories` | `~/.openclaw/skills/<name>/` |
397
+ | Emoji | Not natively supported | `metadata.openclaw.emoji` |