Initial commit

This commit is contained in:
Zhongwei Li
2025-11-29 18:03:07 +08:00
commit b86a9a4d11
5 changed files with 314 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
{
"name": "context-handoff",
"description": "Hierarchical parent-child session context handoff system. Pass context between sessions using /context:send and /context:receive.",
"version": "1.1.0",
"author": {
"name": "Mae Capacite",
"email": "cadrianmae@users.noreply.github.com"
},
"commands": [
"./commands"
]
}

3
README.md Normal file
View File

@@ -0,0 +1,3 @@
# context-handoff
Hierarchical parent-child session context handoff system. Pass context between sessions using /context:send and /context:receive.

93
commands/receive.md Normal file
View File

@@ -0,0 +1,93 @@
---
description: Receive context from parent or child session
argument-hint: <direction> [subject] [path]
allowed-tools: Bash, Read
---
# receive - Receive context from parent or child session
Read and integrate context from a parent or child session handoff file.
## Usage
```
/context:receive parent [subject] [path]
/context:receive child [subject] [path]
```
Both subject and path are optional:
- **subject**: Claude will infer from context if not provided
- **path**: Defaults to `/tmp/claude-ctx/` if not provided
## What it does
1. Checks if `/tmp/claude-ctx/` directory exists using test command
2. Creates directory only if it doesn't exist
3. If creating directory, generates minimal README.md:
```markdown
# Claude Context Handoff Directory
This is an **ephemeral directory** for Claude Code session context handoff. Created by claude slash commands. '/context:send' and '/context:receive'.
```
3. Determines direction: parent-to-child or child-to-parent
4. If subject provided, looks for `{path}/ctx-{direction}-{subject}.md`
5. If no subject, uses wildcard: `{path}/ctx-{direction}-*.md` **sorted by newest first**
6. Path defaults to `/tmp/claude-ctx/` but can be customized
7. Reads and displays context file
8. Integrates context into current session understanding
**Important:** When using wildcard (no subject), files are sorted by modification time with **newest first**, ensuring you get the most recent context.
## Example: Receiving from Parent (Wildcard)
```
/context:receive parent
✓ Searching for context files: /tmp/claude-ctx/ctx-parent-to-child-*.md (newest first)
✓ Found: /tmp/claude-ctx/ctx-parent-to-child-database-migration.md (modified 2 minutes ago)
[Context displayed with parent session details]
Ready to begin focused work based on parent's context!
```
## Example: Receiving from Child with Subject
```
/context:receive child api-implementation
✓ Context received from child session
File: /tmp/claude-ctx/ctx-child-to-parent-api-implementation.md
[Context displayed with completed work summary]
Child session completed. Integrating results back.
```
## Example: Custom Path
```
/context:receive parent database-work ~/Documents/context/
✓ Context received from parent session
File: ~/Documents/context/ctx-parent-to-child-database-work.md
[Context displayed]
```
## What gets loaded
- **Context file content**: Decisions, work done, blockers, next actions
- **Handoff metadata**: Why the handoff occurred, what was planned
- **Related context**: Key information needed to continue
## When to use
- Immediately after starting a new child session from parent
- After resuming parent session when child is complete
- When receiving context from any parent/child session
- To understand what happened in related session
## Related commands
- `/context:send` - Send context to parent/child before switching

157
commands/send.md Normal file
View File

@@ -0,0 +1,157 @@
---
description: Send context to parent or child session before switching
argument-hint: <direction> [subject] [path]
allowed-tools: Bash, Write
---
# send - Send context to child or parent session
Create a context handoff file for transitioning between parent and child sessions.
## Usage
```
/context:send child [subject] [path]
/context:send parent [subject] [path]
```
Both subject and path are optional:
- **subject**: Claude will infer from current conversation context if not provided
- **path**: Defaults to `/tmp/claude-ctx/` if not provided
## What it does
1. Checks if `/tmp/claude-ctx/` directory exists using test command
2. Creates directory only if it doesn't exist
3. If creating directory, generates minimal README.md:
```markdown
# Claude Context Handoff Directory
This is an **ephemeral directory** for Claude Code session context handoff. Created by claude slash commands. '/context:send' and '/context:receive'.
```
3. Determines direction: parent-to-child or child-to-parent
4. If subject provided, creates `{path}/ctx-{direction}-{subject}.md`
5. If no subject, infers from current conversation context and creates file with inferred name
6. Path defaults to `/tmp/claude-ctx/` but can be customized
7. Uses `cat > filename.md << 'EOF'` to clear file and write context
8. Includes:
- Current situation and context
- Decisions made and work completed
- Blockers and next actions
- Files modified
9. Shows clear "next steps" for user
**File naming pattern:**
- `/context:send child` → `/tmp/claude-ctx/ctx-parent-to-child-{inferred-subject}.md`
- `/context:send parent` → `/tmp/claude-ctx/ctx-child-to-parent-{inferred-subject}.md`
## Example: Sending to Child with Subject
```
/context:send child database-migration
✓ Context prepared for child session
File: /tmp/claude-ctx/ctx-parent-to-child-database-migration.md
Next steps:
1. Start child session for focused work
2. In new session, run: /context:receive parent
```
## Example: Sending to Parent (Subject Inferred)
```
/context:send parent
✓ Context prepared for parent session
File: /tmp/claude-ctx/ctx-child-to-parent-api-implementation.md
Next steps:
1. Exit this session
2. Resume parent session
3. In parent session, run: /context:receive child
```
## Example: Custom Path
```
/context:send child feature-work ~/Documents/context/
✓ Context prepared for child session
File: ~/Documents/context/ctx-parent-to-child-feature-work.md
Next steps:
1. Start child session
2. In new session, run: /context:receive parent feature-work ~/Documents/context/
```
## Context File Contents
The context file should include:
### Current Situation
- What work is being done
- Why the handoff is happening
- What the next session needs to focus on
### Decisions Made
- Key technical choices
- Trade-offs considered
- Rationale for decisions
### Work Completed
- What has been implemented
- Files created/modified
- Tests written
- Commits made
### Blockers & Issues
- Problems encountered
- Questions that arose
- Things to investigate
### Next Actions
- What should happen next
- Specific tasks for the receiving session
- Dependencies or prerequisites
## Implementation Pattern
**Create directory if needed:**
```bash
# Check if directory exists, create only if needed
[[ -d /tmp/claude-ctx ]] || {
mkdir -p /tmp/claude-ctx
cat > /tmp/claude-ctx/README.md << 'EOF'
# Claude Context Handoff Directory
This is an **ephemeral directory** for Claude Code session context handoff. Created by claude slash commands. '/context:send' and '/context:receive'.
EOF
}
```
**Write context file:**
Use heredoc to write context file:
```bash
cat > /tmp/claude-ctx/ctx-parent-to-child-{subject}.md << 'EOF'
# Context: Parent → Child
[Context content here]
EOF
```
This pattern clears the file first, preventing accumulation of old context.
## When to use
- Before starting a child session from parent
- Before returning to parent after completing child work
- When switching between hierarchy levels
- When context needs to be passed between sessions
## Related commands
- `/context:receive` - Receive context from parent/child session

49
plugin.lock.json Normal file
View File

@@ -0,0 +1,49 @@
{
"$schema": "internal://schemas/plugin.lock.v1.json",
"pluginId": "gh:cadrianmae/claude-marketplace:plugins/context-handoff",
"normalized": {
"repo": null,
"ref": "refs/tags/v20251128.0",
"commit": "f33b4f1f45d1f941b2c95a2ef6482b1a74b244fa",
"treeHash": "be53bf43df38ea4ae601ad010fbd38316bc3bcaf0453f7558db5505201d419a6",
"generatedAt": "2025-11-28T10:14:27.387891Z",
"toolVersion": "publish_plugins.py@0.2.0"
},
"origin": {
"remote": "git@github.com:zhongweili/42plugin-data.git",
"branch": "master",
"commit": "aa1497ed0949fd50e99e70d6324a29c5b34f9390",
"repoRoot": "/Users/zhongweili/projects/openmind/42plugin-data"
},
"manifest": {
"name": "context-handoff",
"description": "Hierarchical parent-child session context handoff system. Pass context between sessions using /context:send and /context:receive.",
"version": "1.1.0"
},
"content": {
"files": [
{
"path": "README.md",
"sha256": "974e664f78d6d04f0c17da5d2355c48b6c967dcfac64b9539ca38592f2d3ce1e"
},
{
"path": ".claude-plugin/plugin.json",
"sha256": "e0e106974da7b1729d5add9328f52f203346f8ad34a1afc732dc30e413528cb5"
},
{
"path": "commands/receive.md",
"sha256": "97f73bf8ef7f253adf26ee06947d725023b44c744c4d0447731362f114e3c8cc"
},
{
"path": "commands/send.md",
"sha256": "21fca01fe313d1c848bd193c310dd04dac619423e044397b02473ddfe69026f7"
}
],
"dirSha256": "be53bf43df38ea4ae601ad010fbd38316bc3bcaf0453f7558db5505201d419a6"
},
"security": {
"scannedAt": null,
"scannerVersion": null,
"flags": []
}
}