initial version of demo files#1
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR bootstraps a demo TypeScript/Node.js repository aimed at showcasing GitHub Copilot token-optimization practices, including project configuration, Copilot instruction patterns, and sample app/test code.
Changes:
- Added baseline Node/TypeScript project configuration (tsconfig, package metadata, VS Code settings, gitignore).
- Added Copilot guidance assets (lean + bloated instructions, on-demand prompt files, setup steps, and documentation).
- Added a small sample Express app with utilities/services/models plus an example Jest test.
Show a summary per file
| File | Description |
|---|---|
tsconfig.json |
TypeScript compiler configuration for the demo project. |
package.json |
Node project metadata plus build/test/lint/dev scripts and tooling deps. |
.github/copilot-setup-steps.yml |
Automated setup steps intended to install, build, type-check, and test. |
.github/copilot-instructions.md |
Token-optimized, always-loaded Copilot instructions. |
.github/copilot-instructions-bloated.md |
“Before” (verbose) instructions file for comparison. |
.github/prompts/api-design.prompt.md |
On-demand prompt file with API design standards. |
.github/prompts/testing.prompt.md |
On-demand prompt file with testing standards. |
.github/prompts/deploy-checklist.prompt.md |
On-demand prompt file with deploy checklist guidance. |
.vscode/settings.json |
Workspace settings (format-on-save, Prettier, TS import style). |
.vscode/extensions.json |
Recommended VS Code extensions for Copilot usage. |
.gitignore |
Basic Node build/artifact/environment ignores. |
README.md |
Repository purpose, file map, structure, and usage guidance. |
docs/content-exclusion-patterns.md |
Starter patterns for Copilot content exclusion configuration. |
docs/caveman-instructions-examples.md |
Instruction-compression examples and rationale. |
src/index.ts |
Express app entry point (middleware + health endpoint). |
src/routes/users.ts |
Example users route handler demonstrating response wrapping. |
src/utils/helpers.ts |
Utility helpers (date formatting, request IDs, response envelope, etc.). |
src/models/user.ts |
Basic User model and filter types. |
src/services/userService.ts |
Example service logic + “poorly named” comparison function. |
src/services/billingService.ts |
Example billing plan model + invoice/currency helpers. |
src/services/notificationService.ts |
Example notification payload + placeholder send/build functions. |
src/config/database.ts |
Example env-driven database configuration helper. |
src/__tests__/userService.test.ts |
Jest tests for filterActiveUsersByLastLogin. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 21/23 changed files
- Comments generated: 9
Comment on lines
+16
to
+18
| - name: Install dependencies | ||
| run: npm ci | ||
|
|
Comment on lines
+11
to
+13
| export function generateRequestId(): string { | ||
| return `req_${Date.now()}_${Math.random().toString(36).slice(2, 9)}`; | ||
| } |
Comment on lines
+14
to
+17
| .sort( | ||
| (a, b) => | ||
| new Date(b.lastLoginAt).getTime() - new Date(a.lastLoginAt).getTime() | ||
| ); |
Comment on lines
+24
to
+26
| export function processData(data: any[]): any[] { | ||
| return data.filter((d) => d.isActive).sort((a, b) => b.lastLoginAt - a.lastLoginAt); | ||
| } |
Comment on lines
+12
to
+14
| ## File Placement | ||
| - Co-locate: `src/services/__tests__/userService.test.ts` | ||
| - Name: `{module}.test.ts` |
Comment on lines
+12
to
+14
| host: process.env.DB_HOST || "localhost", | ||
| port: parseInt(process.env.DB_PORT || "5432"), | ||
| database: process.env.DB_NAME || "token_demo", |
Comment on lines
+1
to
+13
| import { Router } from "express"; | ||
| import { filterActiveUsersByLastLogin } from "../services/userService"; | ||
| import { wrapResponse } from "../utils/helpers"; | ||
|
|
||
| const router = Router(); | ||
|
|
||
| // GET /api/v1/users — list active users | ||
| router.get("/", async (req, res) => { | ||
| try { | ||
| // In production, fetch from database | ||
| const allUsers: any[] = []; // placeholder | ||
| const activeUsers = filterActiveUsersByLastLogin(allUsers); | ||
| res.json(wrapResponse(activeUsers, { count: activeUsers.length })); |
Comment on lines
+1
to
+25
| { | ||
| "name": "token-optimization-demos", | ||
| "version": "1.0.0", | ||
| "description": "Companion repo for Token Optimization YouTube video by Mickey Gousset", | ||
| "main": "src/index.ts", | ||
| "type": "module", | ||
| "scripts": { | ||
| "build": "tsc", | ||
| "test": "jest", | ||
| "lint": "eslint src/", | ||
| "dev": "tsx watch src/index.ts" | ||
| }, | ||
| "keywords": ["github-copilot", "token-optimization", "ai-development"], | ||
| "author": "Mickey Gousset", | ||
| "license": "MIT", | ||
| "devDependencies": { | ||
| "@types/jest": "^29.5.0", | ||
| "@types/node": "^20.0.0", | ||
| "jest": "^29.7.0", | ||
| "ts-jest": "^29.1.0", | ||
| "typescript": "^5.4.0", | ||
| "eslint": "^8.57.0", | ||
| "tsx": "^4.7.0" | ||
| } | ||
| } |
Comment on lines
+1
to
+23
| import express from "express"; | ||
| import { generateRequestId, wrapResponse } from "./utils/helpers"; | ||
|
|
||
| const app = express(); | ||
| app.use(express.json()); | ||
|
|
||
| // Request ID middleware | ||
| app.use((req, res, next) => { | ||
| req.headers["x-request-id"] = generateRequestId(); | ||
| next(); | ||
| }); | ||
|
|
||
| // Health check | ||
| app.get("/health", (req, res) => { | ||
| res.json(wrapResponse({ status: "ok" })); | ||
| }); | ||
|
|
||
| const PORT = process.env.PORT || 3000; | ||
| app.listen(PORT, () => { | ||
| console.log(`Server running on port ${PORT}`); | ||
| }); | ||
|
|
||
| export default app; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request sets up a comprehensive demo repository for token optimization strategies with GitHub Copilot, including project initialization, coding standards, VS Code configuration, documentation, and sample code. The changes establish a clear project structure, provide concise and detailed instructions for Copilot and contributors, and include example source code and tests to illustrate best practices.
Project Initialization and Configuration
package.jsonwith scripts, dependencies (TypeScript, Jest, ESLint), and project metadata for a TypeScript/Node.js stack..vscode/extensions.json) and workspace settings for Prettier formatting and TypeScript import style (.vscode/settings.json). [1] [2].github/copilot-setup-steps.yml) to automate setup, build, type-check, and test steps.Copilot and Contributor Instructions
.github/copilot-instructions-bloated.md) and a compressed, token-optimized (.github/copilot-instructions.md) Copilot instructions file, demonstrating instruction compression techniques. [1] [2]docs/content-exclusion-patterns.md.docs/caveman-instructions-examples.md.Documentation and Project Structure
README.mdto explain the purpose of the repo, its structure, usage instructions, and the five rules of token optimization.Sample Source Code and Tests
src/models/user.ts), services (src/services/userService.ts,src/services/billingService.ts), Express route (src/routes/users.ts), configuration (src/config/database.ts), and utility helpers (src/utils/helpers.ts) to demonstrate best practices. [1] [2] [3] [4]src/index.ts.filterActiveUsersByLastLoginusing Jest, covering happy path and error cases (src/__tests__/userService.test.ts).These changes together create a well-structured, instructional demo repository for Copilot token optimization and modern TypeScript/Node.js development.
References:
[1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18]