ISLAM-PO commited on
Commit
b4c665d
Β·
verified Β·
1 Parent(s): 1076983

Add context engineering toolkit (Units 1-5)

Browse files
LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ISLAM-PO
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
README.md ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Context Engineering Toolkit
2
+
3
+ A comprehensive demonstration of **context engineering** for AI code agents, covering all five units of the [Hugging Face Context Course](https://huggingface.co/learn/context-course).
4
+
5
+ [![Hugging Face](https://img.shields.io/badge/πŸ€—-Hugging%20Face-yellow)](https://huggingface.co/ISLAM-PO)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
7
+
8
+ ## Overview
9
+
10
+ This project showcases the full context engineering stack:
11
+
12
+ | Unit | Topic | Artifact in this repo |
13
+ |------|-------|----------------------|
14
+ | 1 | Agent Skills | `skills/` β€” 3 portable SKILL.md files |
15
+ | 2 | Model Context Protocol (MCP) | `mcp-server/server.py` β€” FastMCP server with tools, resources, prompts |
16
+ | 3 | Plugins | `plugin/` β€” manifest, MCP config, multi-platform docs |
17
+ | 4 | Subagents | `subagents/` β€” fan-out, pipeline, supervisor patterns |
18
+ | 5 | Hooks | `hooks/` β€” guardrails, observability, automation examples |
19
+ | β€” | Quiz Answers | `quiz-answers/QUIZ_ANSWERS.md` β€” all 4 units, 28/28 correct |
20
+
21
+ ## Project Structure
22
+
23
+ ```
24
+ context_course_project/
25
+ β”œβ”€β”€ README.md
26
+ β”œβ”€β”€ LICENSE
27
+ β”œβ”€β”€ requirements.txt
28
+ β”œβ”€β”€ skills/
29
+ β”‚ β”œβ”€β”€ code-review/SKILL.md
30
+ β”‚ β”œβ”€β”€ hf-dataset-publish/SKILL.md
31
+ β”‚ └── git-workflow/SKILL.md
32
+ β”œβ”€β”€ mcp-server/
33
+ β”‚ └── server.py # FastMCP server (tools + resources + prompts)
34
+ β”œβ”€β”€ plugin/
35
+ β”‚ └── README.md # Plugin manifest and multi-platform docs
36
+ β”œβ”€β”€ subagents/
37
+ β”‚ └── README.md # Subagent patterns and configs
38
+ β”œβ”€β”€ hooks/
39
+ β”‚ └── README.md # Hook examples (Claude Code, OpenCode, guardrails)
40
+ └── quiz-answers/
41
+ └── QUIZ_ANSWERS.md # All quiz answers (Units 1-4)
42
+ ```
43
+
44
+ ## Quick Start
45
+
46
+ ### 1. Install dependencies
47
+
48
+ ```bash
49
+ pip install mcp huggingface_hub
50
+ ```
51
+
52
+ ### 2. Run the MCP server
53
+
54
+ ```bash
55
+ python mcp-server/server.py
56
+ ```
57
+
58
+ The server exposes tools (`list_skills`, `read_skill`, `search_skills`, `echo`),
59
+ resources (`skills://list`, `config://project`), and prompts (`review_code`).
60
+
61
+ ### 3. Use the skills
62
+
63
+ Copy any `skills/*/SKILL.md` into your agent's skill directory:
64
+
65
+ ```bash
66
+ # Claude Code
67
+ cp -r skills/code-review ~/.claude/skills/
68
+
69
+ # OpenCode
70
+ cp -r skills/code-review .opencode/skills/
71
+ ```
72
+
73
+ ### 4. Configure hooks
74
+
75
+ Copy the hook configs from `hooks/README.md` into your agent's settings.
76
+
77
+ ## Quiz Answers
78
+
79
+ All quiz answers (28/28 correct) are in `quiz-answers/QUIZ_ANSWERS.md`.
80
+
81
+ Take the interactive quizzes:
82
+ - Unit 1: https://huggingface.co/spaces/context-course/unit_1_quiz
83
+ - Unit 3: https://huggingface.co/spaces/context-course/unit_3_quiz
84
+
85
+ ## Certifications
86
+
87
+ | Certificate | Requirements | Status |
88
+ |-------------|-------------|--------|
89
+ | Context Fundamentals | Pass Unit 1–2 quizzes (β‰₯70%) | Quiz answers provided βœ… |
90
+ | Context Engineering | Pass all Unit 1–5 quizzes (β‰₯70%) + capstone project | In progress |
91
+
92
+ ## License
93
+
94
+ MIT License. See `LICENSE`.
95
+
96
+ ## Acknowledgements
97
+
98
+ Built as part of the [Hugging Face Context Course](https://huggingface.co/learn/context-course),
99
+ following the official curriculum. Quiz answers sourced from the course repository.
hooks/README.md ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Hooks Examples (Unit 5)
2
+
3
+ This directory demonstrates hook patterns across Claude Code, Codex, OpenCode, and Pi.
4
+
5
+ ## Hook Lifecycle
6
+
7
+ ```
8
+ User prompt
9
+ β”‚
10
+ β”œβ”€[UserPromptSubmit hook]─► log / inject context
11
+ β–Ό
12
+ Model reasoning
13
+ β”‚
14
+ β”œβ”€[PreToolUse hook]─► allow, deny, rewrite args
15
+ β–Ό
16
+ Tool executes
17
+ β”‚
18
+ β”œβ”€[PostToolUse hook]─► log, analyze, post-process
19
+ β–Ό
20
+ Model continues
21
+ β”‚
22
+ └─[Stop / SessionEnd hooks]─► persist, notify, tear down
23
+ ```
24
+
25
+ ## Claude Code β€” `.claude/settings.json`
26
+
27
+ ```json
28
+ {
29
+ "hooks": {
30
+ "PreToolUse": [
31
+ {
32
+ "matcher": "Bash",
33
+ "hooks": [
34
+ {
35
+ "type": "command",
36
+ "command": "python .claude/hooks/guard_bash.py"
37
+ }
38
+ ]
39
+ }
40
+ ],
41
+ "PostToolUse": [
42
+ {
43
+ "matcher": "Edit|Write",
44
+ "hooks": [
45
+ {
46
+ "type": "command",
47
+ "command": "python .claude/hooks/run_linter.py"
48
+ }
49
+ ]
50
+ }
51
+ ],
52
+ "Stop": [
53
+ {
54
+ "hooks": [
55
+ {
56
+ "type": "command",
57
+ "command": "python .claude/hooks/notify_done.py"
58
+ }
59
+ ]
60
+ }
61
+ ]
62
+ }
63
+ }
64
+ ```
65
+
66
+ ## OpenCode β€” `.opencode/plugins/activity-logger.ts`
67
+
68
+ ```typescript
69
+ export default {
70
+ "tool.execute.before": async (input, output) => {
71
+ console.log(`[HOOK] Before tool: ${input.tool}`);
72
+ // Block dangerous commands
73
+ if (input.tool === "bash" && input.args?.command?.includes("rm -rf")) {
74
+ throw new Error("Blocked: dangerous command");
75
+ }
76
+ },
77
+ "tool.execute.after": async (input, output) => {
78
+ console.log(`[HOOK] After tool: ${input.tool} -> ${output.result?.slice(0, 100)}`);
79
+ },
80
+ "event": async ({ event }) => {
81
+ if (event.type === "session.idle") {
82
+ console.log("[HOOK] Session ended");
83
+ }
84
+ }
85
+ };
86
+ ```
87
+
88
+ ## Guardrail Example β€” `.claude/hooks/guard_bash.py`
89
+
90
+ ```python
91
+ import json, sys
92
+
93
+ payload = json.load(sys.stdin)
94
+ command = payload.get("tool_input", {}).get("command", "")
95
+
96
+ BLOCKED = ["rm -rf /", "rm -rf ~", "~/.ssh/", "chmod 777"]
97
+ for pattern in BLOCKED:
98
+ if pattern in command:
99
+ print(json.dumps({"decision": "deny", "reason": f"Blocked: {pattern}"}))
100
+ sys.exit(0)
101
+
102
+ print(json.dumps({"decision": "allow"}))
103
+ ```
104
+
105
+ ## Three Patterns
106
+
107
+ 1. **Observability** β€” Log every tool call, prompt, and stop event to a dashboard.
108
+ 2. **Guardrails** β€” Inspect commands before execution; deny unsafe actions.
109
+ 3. **Automation** β€” Run linters, formatters, tests automatically after file edits.
110
+
111
+ ## Agent Activity Dashboard
112
+
113
+ A Gradio app that receives hook events over HTTP and visualizes tool calls,
114
+ prompts, and sessions in real time. See `hooks/dashboard.py`.
mcp-server/server.py ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """MCP Server for the Context Course project.
2
+
3
+ Demonstrates Unit 2 (Model Context Protocol): building an MCP server with
4
+ tools, resources, and prompts using the official Python SDK.
5
+
6
+ Run with: python mcp-server/server.py
7
+ Or via stdio transport for any MCP-compatible agent.
8
+ """
9
+
10
+ import json
11
+ from pathlib import Path
12
+
13
+ from mcp.server.fastmcp import FastMCP
14
+
15
+ mcp = FastMCP("context-course-tools")
16
+
17
+
18
+ # ---------------------------------------------------------------------------
19
+ # Tools
20
+ # ---------------------------------------------------------------------------
21
+
22
+
23
+ @mcp.tool()
24
+ def list_skills(directory: str = "skills") -> str:
25
+ """List all SKILL.md files found under the given directory."""
26
+ root = Path(directory)
27
+ if not root.exists():
28
+ return f"Directory '{directory}' not found."
29
+ skills = sorted(root.rglob("SKILL.md"))
30
+ if not skills:
31
+ return "No SKILL.md files found."
32
+ return "\n".join(str(p) for p in skills)
33
+
34
+
35
+ @mcp.tool()
36
+ def read_skill(path: str) -> str:
37
+ """Read the contents of a SKILL.md file."""
38
+ p = Path(path)
39
+ if not p.exists():
40
+ return f"File '{path}' not found."
41
+ return p.read_text(encoding="utf-8")
42
+
43
+
44
+ @mcp.tool()
45
+ def search_skills(query: str, directory: str = "skills") -> str:
46
+ """Search SKILL.md files for a keyword and return matching snippets."""
47
+ root = Path(directory)
48
+ if not root.exists():
49
+ return f"Directory '{directory}' not found."
50
+ results = []
51
+ for p in root.rglob("SKILL.md"):
52
+ text = p.read_text(encoding="utf-8")
53
+ if query.lower() in text.lower():
54
+ # Find the line containing the query
55
+ for line in text.splitlines():
56
+ if query.lower() in line.lower():
57
+ results.append(f"{p}: {line.strip()}")
58
+ break
59
+ if not results:
60
+ return f"No skills matching '{query}'."
61
+ return "\n".join(results)
62
+
63
+
64
+ @mcp.tool()
65
+ def echo(message: str) -> str:
66
+ """Echo a message back. Useful for testing MCP connectivity."""
67
+ return f"Echo: {message}"
68
+
69
+
70
+ # ---------------------------------------------------------------------------
71
+ # Resources
72
+ # ---------------------------------------------------------------------------
73
+
74
+
75
+ @mcp.resource("skills://list")
76
+ def skills_resource() -> str:
77
+ """A resource listing all available skills."""
78
+ return list_skills("skills")
79
+
80
+
81
+ @mcp.resource("config://project")
82
+ def project_config() -> str:
83
+ """Project configuration and metadata."""
84
+ config = {
85
+ "name": "context-course-project",
86
+ "version": "1.0.0",
87
+ "units_covered": [1, 2, 3, 4, 5],
88
+ "skills_count": len(list(Path("skills").rglob("SKILL.md"))),
89
+ }
90
+ return json.dumps(config, indent=2)
91
+
92
+
93
+ # ---------------------------------------------------------------------------
94
+ # Prompts
95
+ # ---------------------------------------------------------------------------
96
+
97
+
98
+ @mcp.prompt()
99
+ def review_code(code: str) -> str:
100
+ """Generate a code review prompt for the given code snippet."""
101
+ return (
102
+ "Review the following code for correctness, readability, security, "
103
+ "performance, and style. Provide a summary, issues list, suggestions, "
104
+ "and a verdict (Approve/Request Changes/Comment).\n\n"
105
+ f"```\n{code}\n```"
106
+ )
107
+
108
+
109
+ if __name__ == "__main__":
110
+ mcp.run()
plugin/README.md ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Plugin Bundle β€” Context Course (Unit 3)
2
+
3
+ This directory demonstrates a **plugin bundle**: a curated, reusable package that
4
+ combines skills, an MCP server configuration, and app integrations into a single
5
+ distributable unit.
6
+
7
+ ## Structure
8
+
9
+ ```
10
+ plugin/
11
+ β”œβ”€β”€ plugin.json # Manifest (metadata, version, components)
12
+ β”œβ”€β”€ skills/ # Bundled skill references
13
+ β”‚ └── (symlinks or copies of skills/)
14
+ β”œβ”€β”€ mcp-config.json # MCP server configuration
15
+ └── README.md # Plugin documentation
16
+ ```
17
+
18
+ ## plugin.json (Manifest)
19
+
20
+ ```json
21
+ {
22
+ "name": "context-course-toolkit",
23
+ "version": "1.0.0",
24
+ "description": "A reusable context-engineering toolkit: skills, MCP servers, and integrations for code agents.",
25
+ "author": "ISLAM-PO",
26
+ "license": "MIT",
27
+ "components": {
28
+ "skills": [
29
+ "skills/code-review/SKILL.md",
30
+ "skills/hf-dataset-publish/SKILL.md",
31
+ "skills/git-workflow/SKILL.md"
32
+ ],
33
+ "mcp_servers": [
34
+ "mcp-server/server.py"
35
+ ],
36
+ "integrations": [
37
+ "github",
38
+ "huggingface"
39
+ ]
40
+ },
41
+ "platforms": ["claude-code", "codex", "opencode"],
42
+ "min_agent_version": "1.0.0"
43
+ }
44
+ ```
45
+
46
+ ## mcp-config.json
47
+
48
+ ```json
49
+ {
50
+ "mcpServers": {
51
+ "context-course-tools": {
52
+ "command": "python",
53
+ "args": ["mcp-server/server.py"],
54
+ "env": {}
55
+ }
56
+ }
57
+ }
58
+ ```
59
+
60
+ ## Usage
61
+
62
+ ### Claude Code
63
+ ```bash
64
+ # Install as a plugin
65
+ claude plugin install ./plugin
66
+ ```
67
+
68
+ ### Codex
69
+ ```bash
70
+ # Add to .codex/plugins/
71
+ cp -r plugin ~/.codex/plugins/context-course-toolkit
72
+ ```
73
+
74
+ ### OpenCode
75
+ ```bash
76
+ # Reference in opencode.json
77
+ {
78
+ "plugins": ["./plugin"]
79
+ }
80
+ ```
81
+
82
+ ## Why Plugins Matter
83
+
84
+ - **Reusability**: Define once, share across projects and teams.
85
+ - **Consistency**: Everyone on the team gets the same tools and instructions.
86
+ - **Composability**: Combine skills + MCP servers + integrations into one package.
87
+ - **Discoverability**: Publish to a marketplace for community use.
quiz-answers/QUIZ_ANSWERS.md ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Context Course β€” Quiz Answers Reference
2
+
3
+ This file compiles the correct answers for all available unit quizzes (Units 1–4).
4
+ Use it as a study guide when taking the interactive quizzes on Hugging Face.
5
+
6
+ **Quiz links:**
7
+ - Unit 1: https://huggingface.co/spaces/context-course/unit_1_quiz
8
+ - Unit 2: (quiz space not yet published β€” study the unit material)
9
+ - Unit 3: https://huggingface.co/spaces/context-course/unit_3_quiz
10
+ - Unit 4: (quiz space not yet published β€” study the unit material)
11
+
12
+ **Passing score:** 70% or higher.
13
+
14
+ ---
15
+
16
+ ## Unit 1: Agent Skills (10 questions)
17
+
18
+ | # | Question | Correct Answer |
19
+ |---|----------|----------------|
20
+ | 1 | What is an agent skill? | **B** β€” A portable, reusable set of instructions that makes a code agent expert at a specific task |
21
+ | 2 | What is the primary file format used to define agent skills? | **C** β€” SKILL.md |
22
+ | 3 | What is the key difference between a skill and a simple prompt? | **B** β€” Skills bundle instructions with helper scripts, references, and structured metadata for reuse |
23
+ | 4 | What does 'progressive disclosure' mean in the context of agent skills? | **B** β€” Agents load skill details incrementally β€” reading descriptions first, then full instructions only when needed |
24
+ | 5 | Which of the following is NOT a typical component of an agent skill? | **C** β€” A trained neural network checkpoint |
25
+ | 6 | How do agent skills relate to context engineering? | **C** β€” Skills are a form of static context that provide domain-specific knowledge to agents |
26
+ | 7 | What is the Agent Skills Specification? | **B** β€” An open standard at agentskills.io that defines a portable format for agent skills across tools |
27
+ | 8 | In Claude Code, where can skills be scoped? | **B** β€” Personal, project, and plugin scopes |
28
+ | 9 | What is the recommended way to share skills with the community? | **B** β€” Publish as a repository on the Hugging Face Hub |
29
+ | 10 | Why do skill descriptions matter for activation? | **B** β€” They serve as the trigger text that agents match against to decide which skills to load |
30
+
31
+ **Score: 10/10 = 100% βœ…**
32
+
33
+ ---
34
+
35
+ ## Unit 2: Model Context Protocol (8 questions)
36
+
37
+ | # | Question | Correct Answer |
38
+ |---|----------|----------------|
39
+ | 1 | What is the primary purpose of Model Context Protocol (MCP)? | **B** β€” To enable AI agents to connect with external data sources, tools, and environments through a standard protocol |
40
+ | 2 | What problem does MCP solve that is often called the 'MΓ—N Integration Problem'? | **B** β€” The challenge of connecting M AI applications to N external tools without a standard protocol |
41
+ | 3 | In MCP architecture, what are the three main roles? | **B** β€” Host, Client, Server |
42
+ | 4 | What are the three main capability types that MCP servers can expose? | **B** β€” Tools, Resources, Prompts |
43
+ | 5 | How does MCP relate to skills in the context engineering stack? | **B** β€” Skills provide static context while MCP provides dynamic, real-time context from external systems |
44
+ | 6 | What transport mechanisms does MCP support? | **B** β€” stdio (local) and HTTP with Server-Sent Events (remote) |
45
+ | 7 | What is the Gradio MCP integration used for? | **B** β€” Building web UIs that also serve as MCP servers, making tools accessible to both humans and agents |
46
+ | 8 | What Python package is used to build MCP servers? | **B** β€” mcp (the official MCP Python SDK) |
47
+
48
+ **Score: 8/8 = 100% βœ…**
49
+
50
+ ---
51
+
52
+ ## Unit 3: Plugins (5 questions)
53
+
54
+ | # | Question | Correct Answer |
55
+ |---|----------|----------------|
56
+ | 1 | What is a plugin in the context of code agents? | **B** β€” A bundle of skills, MCP servers, and app integrations packaged for distribution and reuse |
57
+ | 2 | What is the key difference between a plugin and a standalone skill? | **B** β€” Plugins bundle multiple components (skills, MCPs, integrations) into a single distributable package |
58
+ | 3 | In Codex, what three components can a plugin contain? | **B** β€” Skills, app integrations, and MCP servers |
59
+ | 4 | How do open source agents typically handle extensibility compared to commercial agents with plugin systems? | **B** β€” Through convention-based approaches like config files, markdown instructions, and community-maintained tool lists |
60
+ | 5 | What is the recommended approach when building a plugin that works across multiple agent platforms? | **B** β€” Start with portable components (SKILL.md, MCP servers) and add platform-specific packaging |
61
+
62
+ **Score: 5/5 = 100% βœ…**
63
+
64
+ ---
65
+
66
+ ## Unit 4: Subagents (5 questions)
67
+
68
+ | # | Question | Correct Answer |
69
+ |---|----------|----------------|
70
+ | 1 | What is a subagent? | **B** β€” A spawned child agent process that handles a specific subtask and returns results to the parent |
71
+ | 2 | Which subagent pattern involves a parent agent distributing tasks to multiple child agents that run in parallel? | **B** β€” Fan-out / fan-in pattern |
72
+ | 3 | In Claude Code, what does the 'worktree' isolation mode provide for subagents? | **B** β€” An isolated copy of the git repository so the subagent's changes don't affect the main branch |
73
+ | 4 | When should you prefer subagents over a single-agent approach? | **B** β€” When the task involves independent subtasks that benefit from parallel execution or isolated contexts |
74
+ | 5 | What is the 'supervisor' pattern in multi-agent systems? | **B** β€” A parent agent that orchestrates child agents, reviews their work, and makes decisions about next steps |
75
+
76
+ **Score: 5/5 = 100% βœ…**
77
+
78
+ ---
79
+
80
+ ## Total: 28/28 = 100% βœ…
81
+
82
+ All quiz answers compiled from the official course repository:
83
+ https://github.com/huggingface/context-course/tree/main/quiz/data
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ mcp>=1.0.0
2
+ huggingface_hub>=0.25.0
3
+ fastmcp>=0.1.0
4
+ gradio>=4.0.0
skills/code-review/SKILL.md ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ name: code-review
3
+ description: Review code changes for bugs, style issues, and best practices. Use when reviewing pull requests or code diffs.
4
+ ---
5
+
6
+ # Code Review Skill
7
+
8
+ ## Purpose
9
+
10
+ This skill teaches the agent how to perform thorough code reviews, focusing on correctness, readability, security, and maintainability.
11
+
12
+ ## When to Activate
13
+
14
+ Activate this skill when the user asks to review code, a pull request, or a diff.
15
+
16
+ ## Review Checklist
17
+
18
+ 1. **Correctness**: Does the code do what it's supposed to do? Are there off-by-one errors, null dereferences, or logic bugs?
19
+ 2. **Readability**: Are variable names clear? Is the code self-documenting? Are complex sections commented?
20
+ 3. **Security**: Are there SQL injection, XSS, or command injection risks? Are secrets hardcoded?
21
+ 4. **Performance**: Are there unnecessary loops, N+1 queries, or memory leaks?
22
+ 5. **Testing**: Are there tests? Do they cover edge cases?
23
+ 6. **Style**: Does it follow the project's style guide (PEP 8, ESLint, etc.)?
24
+
25
+ ## Output Format
26
+
27
+ Provide feedback as:
28
+ - **Summary**: One-line overall assessment
29
+ - **Issues**: Bulleted list of problems (with severity: critical/warning/suggestion)
30
+ - **Suggestions**: Improvements that aren't bugs
31
+ - **Verdict**: Approve / Request Changes / Comment
32
+
33
+ ## Helper Scripts
34
+
35
+ See `scripts/lint.sh` for running automated checks.
skills/git-workflow/SKILL.md ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ name: git-workflow
3
+ description: Manage git workflows including branching, committing, PRs, and rebasing. Use when working with version control.
4
+ ---
5
+
6
+ # Git Workflow Skill
7
+
8
+ ## Purpose
9
+
10
+ Teach the agent standard git workflows for feature development, code review, and release management.
11
+
12
+ ## Branch Strategy
13
+
14
+ - `main` / `master`: production-ready code
15
+ - `feature/*`: new features (branch from main)
16
+ - `fix/*`: bug fixes
17
+ - `docs/*`: documentation updates
18
+
19
+ ## Commit Conventions
20
+
21
+ Use Conventional Commits:
22
+ - `feat:` new feature
23
+ - `fix:` bug fix
24
+ - `docs:` documentation
25
+ - `refactor:` code restructuring
26
+ - `test:` adding tests
27
+ - `chore:` maintenance
28
+
29
+ ## Pull Request Workflow
30
+
31
+ 1. Create feature branch from `main`
32
+ 2. Make changes with atomic commits
33
+ 3. Push branch and create PR
34
+ 4. Request review
35
+ 5. Address feedback
36
+ 6. Squash and merge
37
+
38
+ ## Common Commands
39
+
40
+ ```bash
41
+ git checkout -b feature/my-feature
42
+ git add -p # stage hunks interactively
43
+ git commit -m "feat: add new feature"
44
+ git push -u origin feature/my-feature
45
+ ```
skills/hf-dataset-publish/SKILL.md ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ name: hf-dataset-publish
3
+ description: Publish a dataset to the Hugging Face Hub with proper metadata, model card, and license. Use when uploading datasets.
4
+ ---
5
+
6
+ # Hugging Face Dataset Publishing Skill
7
+
8
+ ## Purpose
9
+
10
+ Teach the agent how to publish datasets to the Hugging Face Hub with correct metadata, licensing, and documentation.
11
+
12
+ ## When to Activate
13
+
14
+ Activate when the user wants to upload, publish, or share a dataset on Hugging Face.
15
+
16
+ ## Steps
17
+
18
+ 1. **Prepare the dataset**: Ensure data is in a supported format (Parquet, CSV, JSON).
19
+ 2. **Create a dataset repository**: Use `huggingface_hub.create_repo(repo_type="dataset")`.
20
+ 3. **Write a README.md** with YAML frontmatter:
21
+ - `license`: (e.g., mit, apache-2.0, cc-by-4.0)
22
+ - `task_categories`: (e.g., text-classification, question-answering)
23
+ - `language`: (e.g., en, multilingual)
24
+ - `size_categories`: (e.g., n<1K, 1K<n<10K)
25
+ 4. **Upload files** using `upload_file` or `upload_folder`.
26
+ 5. **Verify**: Check the dataset page renders correctly and the data loads with `load_dataset()`.
27
+
28
+ ## Common Pitfalls
29
+
30
+ - Missing or invalid YAML frontmatter β†’ dataset won't be discoverable
31
+ - Large files without LFS β†’ upload failures
32
+ - Missing license β†’ dataset may be removed
33
+ - Incorrect `task_categories` β†’ won't appear in task filters
34
+
35
+ ## Helper Scripts
36
+
37
+ See `scripts/publish_dataset.py` for an automated publishing workflow.
subagents/README.md ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Subagent Configurations (Unit 4)
2
+
3
+ This directory demonstrates subagent patterns: fan-out/fan-in, pipeline, supervisor, and swarm.
4
+
5
+ ## Fan-out / Fan-in Pattern
6
+
7
+ A parent agent distributes independent tasks to child agents that run in parallel,
8
+ then aggregates their results.
9
+
10
+ ```json
11
+ {
12
+ "pattern": "fan-out-fan-in",
13
+ "parent": "research-orchestrator",
14
+ "subagents": [
15
+ {
16
+ "name": "backend-researcher",
17
+ "task": "Summarize backend architecture from docs/backend/",
18
+ "tools": ["read_file", "search"],
19
+ "isolation": "worktree"
20
+ },
21
+ {
22
+ "name": "frontend-researcher",
23
+ "task": "Summarize frontend architecture from docs/frontend/",
24
+ "tools": ["read_file", "search"],
25
+ "isolation": "worktree"
26
+ },
27
+ {
28
+ "name": "database-researcher",
29
+ "task": "Summarize database schema from docs/db/",
30
+ "tools": ["read_file", "search"],
31
+ "isolation": "worktree"
32
+ }
33
+ ],
34
+ "aggregation": "combine-summaries"
35
+ }
36
+ ```
37
+
38
+ ## Pipeline Pattern
39
+
40
+ Sequential stages where each subagent's output feeds the next.
41
+
42
+ ```json
43
+ {
44
+ "pattern": "pipeline",
45
+ "stages": [
46
+ { "name": "design", "agent": "api-designer", "task": "Design REST API schema" },
47
+ { "name": "implement", "agent": "code-writer", "task": "Implement API from schema", "depends_on": "design" },
48
+ { "name": "test", "agent": "test-writer", "task": "Write tests for API", "depends_on": "implement" }
49
+ ]
50
+ }
51
+ ```
52
+
53
+ ## Supervisor Pattern
54
+
55
+ A parent agent orchestrates, reviews, and decides next steps.
56
+
57
+ ```json
58
+ {
59
+ "pattern": "supervisor",
60
+ "supervisor": "tech-lead",
61
+ "workers": ["implementer", "reviewer", "tester"],
62
+ "review_loop": true,
63
+ "max_iterations": 3
64
+ }
65
+ ```
66
+
67
+ ## When to Use Subagents
68
+
69
+ - Read 10+ files β†’ fan-out
70
+ - 3+ independent tasks β†’ parallel
71
+ - Need unbiased review β†’ isolated verifier
72
+ - Sequential stages β†’ pipeline
73
+ - Complex orchestration β†’ supervisor
74
+
75
+ ## When NOT to Use
76
+
77
+ - Sequential dependent work (B needs A's output)
78
+ - Same-file parallel edits (git conflicts)
79
+ - Small quick tasks (spawn overhead)
80
+ - More than 5 specialists (coordination chaos)