Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .claude/commands/review.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Review the current changes against this project's conventions. Check the diff, tests, validation, error responses, and unintended files. Summarize any issues found and suggest fixes.
21 changes: 21 additions & 0 deletions .claude/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"permissions": {
"allow": [
"mcp__filesystem__list_directory",
"mcp__filesystem__read_file"
]
},
"hooks": {
"PostToolUse": [
{
"matcher": "Write|Edit",
"hooks": [
{
"type": "command",
"command": "npm test"
}
]
}
]
}
}
8 changes: 8 additions & 0 deletions .claude/skills/route-pattern/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
name: route-pattern
description: Follow this project's existing Express route conventions when adding or updating a users API route. Use when asked to create or modify a route in routes/.
---

# Route Pattern

Follow the existing Express router style in `routes/`: use the shared store, validate required input before data access, return JSON responses, and use appropriate HTTP status codes for validation and missing resources.
8 changes: 8 additions & 0 deletions .mcp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "${PWD}/docs"]
}
}
}
8 changes: 8 additions & 0 deletions NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Claude Wiring Notes

- **MCP server:** Connected the credential-free filesystem server at project scope, pointed at `docs/`. The permission rule allows only directory listing and file reading, keeping the server read-only for normal project use.
- **Skill:** Added `route-pattern` to capture the project's Express route conventions. Its description specifically triggers when creating or modifying routes in `routes/`.
- **Command:** Added `/review` as a reusable shortcut for reviewing the current diff, tests, validation, error handling, and unintended files.
- **Hook:** Added a project-level `PostToolUse` hook for `Write|Edit` that runs `npm test` after changes, so the test suite is automatically checked.
- **Headless task:** A scoped headless run should be limited to the tools needed for inspection/testing, such as `Bash(git diff *)`, `Bash(npm test)`, and read-only file access. Claude Code was not available in this environment, so this wiring was prepared without executing the Claude CLI.
- **Model:** Used GPT-5.6 Luna to prepare the project wiring and configuration.
17 changes: 13 additions & 4 deletions db/store.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// A tiny in-memory data store. It stands in for a real database so the
// project stays easy to run. Data is not persisted — it resets every time
// the server restarts.
const fs = require("fs");

Check warning on line 1 in db/store.js

View workflow job for this annotation

GitHub Actions / check

'fs' is assigned a value but never used
const path = require("path");

const FILE = path.join(__dirname, "..", "users.json");

Check warning on line 4 in db/store.js

View workflow job for this annotation

GitHub Actions / check

'FILE' is assigned a value but never used

let users = [
{ id: 1, name: "Ada Lovelace", email: "ada@example.com" },
Expand All @@ -24,4 +25,12 @@
return user;
}

module.exports = { getAllUsers, getUserById, createUser };
function updateUser(id, { name, email }) {
const user = getUserById(id);
if (!user) return null;
user.name = name;
user.email = email;
return user;
}

module.exports = { getAllUsers, getUserById, createUser, updateUser };
24 changes: 11 additions & 13 deletions routes/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,31 @@ const store = require("../db/store");

const router = express.Router();

// GET /users — list every user
router.get("/", (req, res) => {
res.json(store.getAllUsers());
});

// GET /users/:id — fetch a single user, or 404 if it doesn't exist
router.get("/:id", (req, res) => {
const id = Number(req.params.id);
const user = store.getUserById(id);

if (!user) {
return res.status(404).json({ error: "User not found" });
}

if (!user) return res.status(404).json({ error: "User not found" });
res.json(user);
});

// POST /users — create a user; name and email are required
router.post("/", (req, res) => {
const { name, email } = req.body;

if (!name || !email) {
return res.status(400).json({ error: "name and email are required" });
}

if (!name || !email) return res.status(400).json({ error: "name and email are required" });
const user = store.createUser({ name, email });
res.status(201).json(user);
});

router.put("/:id", (req, res) => {
const id = Number(req.params.id);
const { name, email } = req.body;
if (!name || !email) return res.status(400).json({ error: "name and email are required" });
const user = store.updateUser(id, { name, email });
if (!user) return res.status(404).json({ error: "User not found" });
res.json(user);
});

module.exports = router;