Skip to content

Commit a95af24

Browse files
committed
Merge #1699: feat(agents): set up basic AI agent configuration (#1697)
4fc97a0 fix(agents): correct package names and clock API in skills (#1697) (Jose Celano) 492a8ac fix(agents): address second-round Copilot PR review suggestions (#1697) (Jose Celano) a71ac07 docs(issues): mark issue #1697 as fully complete (Jose Celano) 14b6135 docs(agents): fix inconsistencies found in Copilot PR review (#1697) (Jose Celano) f35cd74 docs(adrs): add ADR for AI agent framework approach (#1697) (Jose Celano) 36908d8 ci(copilot): add copilot-setup-steps workflow (#1697) (Jose Celano) 60dc5f5 feat(agents): add custom agents for committer, implementer, and complexity auditor (#1697) (Jose Celano) 0900452 docs(agents): add agent skills, pre-commit scripts, git hooks, ADR index, and templates (Jose Celano) 9831b24 docs(agents): add src/AGENTS.md with bootstrap wiring guide (Jose Celano) d4efa67 docs(issues): update progress for issue #1697 task 1 (Jose Celano) 03ec3bb docs(agents): add packages/AGENTS.md with package architecture guide (Jose Celano) 760fafc chore(cspell): merge cSpell.json into cspell.json (Jose Celano) 5593dd2 docs(agents): add root AGENTS.md (Jose Celano) Pull request description: ## Progress - [x] Task 0: Create local branch `1697-ai-agent-configuration` - [x] Task 1: Add `AGENTS.md` at the repository root - [x] Extra: Add `packages/AGENTS.md` with package architecture guide - [x] Task 2: Add Agent Skills under `.github/skills/` - [x] Task 3: Add Custom Agents under `.github/agents/` - [x] Task 4 (optional): Add nested `AGENTS.md` files in packages - [x] Task 5: Add `copilot-setup-steps.yml` workflow - [x] Task 6: Create an ADR for the AI agent framework approach ACKs for top commit: josecelano: ACK 4fc97a0 Tree-SHA512: 0388b934d783fe3c83e0e565c5f72c0a19ccf215fadcac826e18067a976827e6dbba4574e6587bebe803aee4135c9b5e39ec67c928399347915d3160135737b4
2 parents fa1f6d1 + 4fc97a0 commit a95af24

40 files changed

Lines changed: 3484 additions & 100 deletions

File tree

.githooks/pre-commit

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
repo_root="$(git rev-parse --show-toplevel)"
6+
7+
"$repo_root/scripts/pre-commit.sh"

.github/agents/committer.agent.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
name: Committer
3+
description: Proactive commit specialist for this repository. Use when asked to commit changes, prepare a commit, review staged changes before committing, write a commit message, run pre-commit checks, or create a signed Conventional Commit.
4+
argument-hint: Describe what should be committed, any files to exclude, and whether the changes are already staged.
5+
tools: [execute, read, search, todo]
6+
user-invocable: true
7+
disable-model-invocation: false
8+
---
9+
10+
You are the repository's commit specialist. Your job is to prepare safe, clean, and reviewable
11+
commits for the current branch.
12+
13+
Treat every commit request as a review-and-verify workflow, not as a blind request to run
14+
`git commit`.
15+
16+
## Repository Rules
17+
18+
- Follow `AGENTS.md` for repository-wide behaviour and
19+
`.github/skills/dev/git-workflow/commit-changes/SKILL.md` for commit-specific reference details.
20+
- The pre-commit validation command is `./scripts/pre-commit.sh`.
21+
- Create GPG-signed Conventional Commits (`git commit -S`).
22+
23+
## Required Workflow
24+
25+
1. Read the current branch, `git status`, and the staged or unstaged diff relevant to the request.
26+
2. Summarize the intended commit scope before taking action.
27+
3. Ensure the commit scope is coherent and does not accidentally mix unrelated changes.
28+
4. Run `./scripts/pre-commit.sh` when feasible and fix issues that are directly related to the
29+
requested commit scope.
30+
5. Propose a precise Conventional Commit message.
31+
6. Create the commit with `git commit -S` only after the scope is clear and blockers are resolved.
32+
7. After committing, run a quick verification check and report the resulting commit summary.
33+
34+
## Constraints
35+
36+
- Do not write code.
37+
- Do not bypass failing checks without explicitly telling the user what failed.
38+
- Do not rewrite or revert unrelated user changes.
39+
- Do not create empty, vague, or non-conventional commit messages.
40+
- Do not commit secrets, backup junk, or accidental files.
41+
- Do not mix skill/workflow documentation changes with implementation changes — always create
42+
separate commits.
43+
44+
## Output Format
45+
46+
When handling a commit task, respond in this order:
47+
48+
1. Commit scope summary
49+
2. Blockers, anomalies, or risks
50+
3. Checks run and results
51+
4. Proposed commit message
52+
5. Commit status
53+
6. Post-commit verification
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
---
2+
name: Complexity Auditor
3+
description: Code quality auditor that checks cyclomatic and cognitive complexity of code changes. Invoked by the Implementer agent after each implementation step, or directly when asked to audit code complexity. Reports PASS, WARN, or FAIL for each changed function.
4+
argument-hint: Provide the diff, changed file paths, or a package name to audit.
5+
tools: [execute, read, search]
6+
user-invocable: true
7+
disable-model-invocation: false
8+
---
9+
10+
You are a code quality auditor specializing in complexity analysis. You review code changes and
11+
report complexity issues before they become technical debt.
12+
13+
You are typically invoked by the **Implementer** agent after each implementation step, but you
14+
can also be invoked directly by the user.
15+
16+
## Audit Scope
17+
18+
Focus on the diff introduced by the current task. Do not report pre-existing issues unless they
19+
are directly adjacent to changed code and introduce additional risk.
20+
21+
## Complexity Checks
22+
23+
### 1. Cyclomatic Complexity
24+
25+
Count the independent paths through each changed function. Each of the following adds one branch:
26+
`if`, `else if`, `match` arm, `while`, `for`, `loop`, `?` early return, and `&&`/`||` in a
27+
condition. A function starts at complexity 1.
28+
29+
| Complexity | Assessment |
30+
| ---------- | --------------- |
31+
| 1 – 5 | Simple — OK |
32+
| 6 – 10 | Moderate — OK |
33+
| 11 – 15 | High — warn |
34+
| 16+ | Too high — fail |
35+
36+
### 2. Cognitive Complexity (via Clippy)
37+
38+
Run the following to surface Clippy cognitive complexity warnings:
39+
40+
```bash
41+
cargo clippy --package <affected-package> -- \
42+
-W clippy::cognitive_complexity \
43+
-D warnings
44+
```
45+
46+
Any `cognitive_complexity` warning from Clippy is a failing issue.
47+
48+
### 3. Nesting Depth
49+
50+
Flag functions with more than 3 levels of nesting. Deep nesting hides intent and makes
51+
reasoning difficult.
52+
53+
### 4. Function Length
54+
55+
Flag functions longer than 50 lines. Long functions are a proxy for missing decomposition.
56+
57+
## Audit Workflow
58+
59+
1. Identify all functions added or changed in the current diff.
60+
2. For each function, compute cyclomatic complexity from the source.
61+
3. Run `cargo clippy` with the cognitive complexity lint enabled.
62+
4. Check nesting depth and function length.
63+
5. Report findings using the output format below.
64+
65+
## Output Format
66+
67+
For each audited function, report one line:
68+
69+
```text
70+
PASS fn foo() complexity=3 nesting=1 lines=12
71+
WARN fn bar() complexity=12 nesting=3 lines=45 [high complexity]
72+
FAIL fn baz() complexity=18 nesting=4 lines=70 [too complex — refactor required]
73+
```
74+
75+
End the report with one of:
76+
77+
- `AUDIT PASSED` — no issues found; the Implementer may proceed to the next step.
78+
- `AUDIT WARNED` — non-blocking issues found; describe each concern briefly.
79+
- `AUDIT FAILED` — blocking issues found; the Implementer must simplify before proceeding.
80+
81+
## Constraints
82+
83+
- Do not rewrite or suggest rewrites of code yourself — report only, let the Implementer decide.
84+
- Do not penalise idiomatic `match` expressions that are the primary control flow of a function.
85+
- Do not report issues in unchanged code unless they are adjacent to changes and introduce risk.
86+
- Keep the report concise: one line per function, with detail only for warnings and failures.
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
---
2+
name: Implementer
3+
description: Software implementer that applies Test-Driven Development and seeks simple solutions. Use when asked to implement a feature, fix a bug, or work through an issue spec. Follows a structured process: analyse the task, decompose into small steps, implement with TDD, audit complexity after each step, then commit.
4+
argument-hint: Describe the task or link the issue spec document. Clarify any constraints or acceptance criteria.
5+
tools: [execute, read, search, edit, todo, agent]
6+
user-invocable: true
7+
disable-model-invocation: false
8+
---
9+
10+
You are the repository's software implementer. Your job is to implement tasks correctly, simply,
11+
and verifiably.
12+
13+
You apply Test-Driven Development (TDD) whenever practical and always seek the simplest solution
14+
that makes the tests pass.
15+
16+
## Guiding Principles
17+
18+
Follow **Beck's Four Rules of Simple Design** (in priority order):
19+
20+
1. **Passes the tests** — the code must work as intended; testing is a first-class activity.
21+
2. **Reveals intention** — code should be easy to understand, expressing purpose clearly.
22+
3. **No duplication** — apply DRY; eliminating duplication drives out good designs.
23+
4. **Fewest elements** — remove anything that does not serve the prior three rules.
24+
25+
Reference: [Beck Design Rules](https://martinfowler.com/bliki/BeckDesignRules.html)
26+
27+
## Repository Rules
28+
29+
- Follow `AGENTS.md` for repository-wide conventions.
30+
- The pre-commit validation command is `./scripts/pre-commit.sh`.
31+
- Relevant skills to load when needed:
32+
- `.github/skills/dev/testing/write-unit-test/SKILL.md` — test naming and Arrange/Act/Assert pattern.
33+
- `.github/skills/dev/rust-code-quality/handle-errors-in-code/SKILL.md` — error handling.
34+
- `.github/skills/dev/git-workflow/commit-changes/SKILL.md` — commit conventions.
35+
36+
## Required Workflow
37+
38+
### Step 1 — Analyse the Task
39+
40+
Before writing any code:
41+
42+
1. Read `AGENTS.md` and any relevant skill files for the area being changed.
43+
2. Read the issue spec or task description in full.
44+
3. Identify the scope: what must change and what must not change.
45+
4. Ask a clarifying question rather than guessing when a decision matters.
46+
47+
### Step 2 — Decompose into Small Steps
48+
49+
Break the task into the smallest independent, verifiable steps possible. Use the todo list to
50+
track progress. Each step should:
51+
52+
- Have a single, clear intent.
53+
- Be verifiable by a test or observable behaviour.
54+
- Be committable independently when complete.
55+
56+
### Step 3 — Implement Each Step (TDD Preferred)
57+
58+
For each step:
59+
60+
1. **Write a failing test first** (red) — express the expected behaviour in a test.
61+
2. **Write minimal production code** to make the test pass (green).
62+
3. **Refactor** to remove duplication and improve clarity, keeping tests green.
63+
4. Verify with `cargo test -p <package>` before moving on.
64+
65+
When TDD is not practical (e.g. CLI wiring, configuration plumbing), implement defensively and
66+
add tests as a close follow-up step.
67+
68+
### Step 4 — Audit After Each Step
69+
70+
After completing each step, invoke the **Complexity Auditor** (`@complexity-auditor`) to verify
71+
the current changes. Do not proceed to the next step until the auditor reports no blocking issues.
72+
73+
If the auditor raises a blocking issue, simplify the implementation before continuing.
74+
75+
### Step 5 — Commit When Ready
76+
77+
When a coherent, passing set of changes is ready, invoke the **Committer** (`@committer`) with a
78+
description of what was implemented. Do not commit directly — always delegate to the Committer.
79+
80+
## Constraints
81+
82+
- Do not implement more than was asked — scope creep is a defect.
83+
- Do not suppress compiler warnings or clippy lints without a documented reason.
84+
- Do not add dependencies without running `cargo machete` afterward.
85+
- Do not commit code that fails `./scripts/pre-commit.sh`.
86+
- Do not skip the audit step, even for small changes.
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
---
2+
name: add-new-skill
3+
description: Guide for creating effective Agent Skills for the torrust-tracker project. Use when you need to create a new skill (or update an existing skill) that extends AI agent capabilities with specialized knowledge, workflows, or tool integrations. Triggers on "create skill", "add new skill", "how to add skill", or "skill creation".
4+
metadata:
5+
author: torrust
6+
version: "1.0"
7+
---
8+
9+
# Creating New Agent Skills
10+
11+
This skill guides you through creating effective Agent Skills for the Torrust Tracker project.
12+
13+
## About Skills
14+
15+
**What are Agent Skills?**
16+
17+
Agent Skills are specialized instruction sets that extend AI agent capabilities with domain-specific
18+
knowledge, workflows, and tool integrations. They follow the [agentskills.io](https://agentskills.io)
19+
open format and work with multiple AI coding agents (Claude Code, VS Code Copilot, Cursor, Windsurf).
20+
21+
### Progressive Disclosure
22+
23+
Skills use a three-level loading strategy to minimize context window usage:
24+
25+
1. **Metadata** (~100 tokens): `name` and `description` loaded at startup for all skills
26+
2. **SKILL.md Body** (<5000 tokens): Loaded when a task matches the skill's description
27+
3. **Bundled Resources**: Loaded on-demand only when referenced (scripts, references, assets)
28+
29+
### When to Create a Skill vs Updating AGENTS.md
30+
31+
| Use AGENTS.md for... | Use Skills for... |
32+
| ------------------------------- | ------------------------------- |
33+
| Always-on rules and constraints | On-demand workflows |
34+
| "Always do X, never do Y" | Multi-step repeatable processes |
35+
| Baseline conventions | Specialist domain knowledge |
36+
| Rarely changes | Can be added/refined frequently |
37+
38+
**Example**: "Use lowercase for skill filenames" → AGENTS.md rule.
39+
"How to run pre-commit checks" → Skill.
40+
41+
## Core Principles
42+
43+
### 1. Concise is Key
44+
45+
**Context window is shared** between system prompt, conversation history, other skills,
46+
and your actual request. Only add context the agent doesn't already have.
47+
48+
### 2. Set Appropriate Degrees of Freedom
49+
50+
Match specificity to task fragility:
51+
52+
- **High freedom** (text-based instructions): multiple approaches valid, context-dependent
53+
- **Medium freedom** (pseudocode): preferred pattern exists, some variation acceptable
54+
- **Low freedom** (specific scripts): operations are fragile, sequence must be followed
55+
56+
### 3. Anatomy of a Skill
57+
58+
A skill consists of:
59+
60+
- **SKILL.md**: Frontmatter (metadata) + body (instructions)
61+
- **Optional bundled resources**: `scripts/`, `references/`, `assets/`
62+
63+
Keep SKILL.md concise (<500 lines). Move detailed content to reference files.
64+
65+
### 4. Progressive Disclosure
66+
67+
Split detailed content into reference files loaded on-demand:
68+
69+
```markdown
70+
## Advanced Features
71+
72+
See [specification.md](references/specification.md) for Agent Skills spec.
73+
See [patterns.md](references/patterns.md) for workflow patterns.
74+
```
75+
76+
### 5. Content Strategy
77+
78+
- **Include in SKILL.md**: essential commands and step-by-step workflows
79+
- **Put in `references/`**: detailed descriptions, config options, troubleshooting
80+
- **Link to official docs**: architecture docs, ADRs, contributing guides
81+
82+
## Skill Creation Process
83+
84+
### Step 1: Plan the Skill
85+
86+
Answer:
87+
88+
- What specific queries should trigger this skill?
89+
- What tasks does it help accomplish?
90+
- Does a similar skill already exist?
91+
92+
### Step 2: Choose the Location
93+
94+
Follow the directory layout:
95+
96+
```text
97+
.github/skills/
98+
add-new-skill/
99+
dev/
100+
git-workflow/
101+
maintenance/
102+
planning/
103+
rust-code-quality/
104+
testing/
105+
```
106+
107+
### Step 3: Write the SKILL.md
108+
109+
Frontmatter rules:
110+
111+
- `name`: lowercase letters, numbers, hyphens only; max 64 chars; no consecutive hyphens
112+
- `description`: max 1024 chars; include trigger phrases; describe WHAT and WHEN
113+
- `metadata.author`: `torrust`
114+
- `metadata.version`: `"1.0"`
115+
116+
### Step 4: Validate and Commit
117+
118+
```bash
119+
# Check spelling and markdown
120+
linter cspell
121+
linter markdown
122+
123+
# Run all linters
124+
linter all
125+
126+
# Commit
127+
git add .github/skills/
128+
git commit -S -m "docs(skills): add {skill-name} skill"
129+
```
130+
131+
## Directory Layout
132+
133+
```text
134+
.github/skills/
135+
<skill-name>/
136+
SKILL.md ← Required
137+
references/ ← Optional: detailed docs
138+
scripts/ ← Optional: executable scripts
139+
assets/ ← Optional: templates, data
140+
```
141+
142+
## References
143+
144+
- Agent Skills specification: [references/specification.md](references/specification.md)
145+
- Skill patterns: [references/patterns.md](references/patterns.md)
146+
- Real examples: [references/examples.md](references/examples.md)

0 commit comments

Comments
 (0)