Skip to content

Commit 18f4205

Browse files
Kasper Jungeclaude
authored andcommitted
docs: document Skill provenance attributes for users who want to track skill origins programmatically
The SDK docs were missing three attributes on the Skill class (handle, source, revision) and didn't explain the metadata dict contents. Also adds EDITOR/VISUAL env var note to configuration page for users who hit errors with agr config edit. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 9acf544 commit 18f4205

2 files changed

Lines changed: 56 additions & 7 deletions

File tree

docs/docs/configuration.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ All config operations use the `agr config` command:
239239
```bash
240240
agr config show # View formatted config
241241
agr config path # Print agr.toml path
242-
agr config edit # Open in $EDITOR
242+
agr config edit # Open in $EDITOR or $VISUAL
243243
agr config get <key> # Read a value
244244
agr config set <key> <values> # Write a value
245245
agr config add <key> <values> # Append to a list
@@ -249,4 +249,11 @@ agr config unset <key> # Clear to default
249249

250250
Add `-g` to any command to operate on the global config (`~/.agr/agr.toml`).
251251

252+
!!! note "`agr config edit` requires an editor"
253+
`agr config edit` opens `agr.toml` in your `$EDITOR` (or `$VISUAL`).
254+
If neither environment variable is set, you'll get an error. Set one:
255+
```bash
256+
export EDITOR="vim" # or nano, code --wait, etc.
257+
```
258+
252259
See the [CLI Reference](reference.md) for full details.

docs/docs/sdk.md

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ print(skill.prompt)
3434

3535
### From GitHub
3636

37-
`Skill.from_git()` downloads a skill from GitHub and caches it locally. Subsequent calls use the cache unless the remote has new commits.
37+
`Skill.from_git()` downloads a skill from GitHub and caches it locally. On
38+
subsequent calls, agr checks the remote HEAD commit — if the cached revision
39+
matches, it returns the cached copy without re-downloading.
3840

3941
```python
4042
from agr import Skill
@@ -45,7 +47,7 @@ skill = Skill.from_git("kasperjunge/commit")
4547
# Explicit repo
4648
skill = Skill.from_git("anthropics/skills/code-review")
4749

48-
# Force re-download (skip cache)
50+
# Force re-download even if cached (useful after upstream changes)
4951
skill = Skill.from_git("kasperjunge/commit", force_download=True)
5052
```
5153

@@ -62,13 +64,53 @@ skill = Skill.from_local("/absolute/path/to/skill")
6264

6365
| Property | Type | Description |
6466
|----------|------|-------------|
65-
| `name` | `str` | Skill name |
67+
| `name` | `str` | Skill name (directory name) |
6668
| `path` | `Path` | Path to skill directory (cached or local) |
67-
| `prompt` | `str` | Contents of `SKILL.md` (lazy-loaded) |
68-
| `files` | `list[str]` | Relative file paths in the skill directory (lazy-loaded) |
69-
| `metadata` | `dict` | Skill metadata (name, path, source, revision, handle, is_local) |
69+
| `handle` | `ParsedHandle \| None` | Parsed handle with owner, repo, and name components |
70+
| `source` | `str \| None` | Source name the skill was fetched from (e.g., `"github"`) |
71+
| `revision` | `str \| None` | Git commit hash (first 12 chars) of the fetched revision |
72+
| `prompt` | `str` | Contents of `SKILL.md` (lazy-loaded on first access) |
73+
| `files` | `list[str]` | Relative file paths in the skill directory (lazy-loaded on first access) |
74+
| `metadata` | `dict` | Combined metadata dict (see below) |
7075
| `content_hash` | `str \| None` | Content hash from `.agr.json`, if present |
7176

77+
The `handle`, `source`, and `revision` attributes are set by `from_git()`. For
78+
locally loaded skills, `source` and `revision` are `None`.
79+
80+
### Provenance: handle, source, revision
81+
82+
When you load a skill from GitHub, agr records where it came from:
83+
84+
```python
85+
skill = Skill.from_git("anthropics/skills/code-review")
86+
87+
# Which repo was it fetched from?
88+
print(skill.source) # "github"
89+
print(skill.revision) # "a1b2c3d4e5f6" (short commit hash)
90+
91+
# Access handle components
92+
print(skill.handle.username) # "anthropics"
93+
print(skill.handle.repo) # "skills"
94+
print(skill.handle.name) # "code-review"
95+
```
96+
97+
### The metadata dict
98+
99+
The `metadata` property returns a dict combining all provenance info:
100+
101+
```python
102+
skill = Skill.from_git("anthropics/skills/code-review")
103+
print(skill.metadata)
104+
# {
105+
# "name": "code-review",
106+
# "path": "/Users/you/.cache/agr/skills/anthropics/skills/code-review/a1b2c3d4e5f6",
107+
# "source": "github",
108+
# "revision": "a1b2c3d4e5f6",
109+
# "handle": "anthropics/skills/code-review",
110+
# "is_local": False,
111+
# }
112+
```
113+
72114
### Reading Files
73115

74116
```python

0 commit comments

Comments
 (0)