Skip to content

initial version of demo files#1

Merged
mickeygousset merged 1 commit into
mainfrom
mickeygousset/initial-files
Jun 4, 2026
Merged

initial version of demo files#1
mickeygousset merged 1 commit into
mainfrom
mickeygousset/initial-files

Conversation

@mickeygousset

Copy link
Copy Markdown
Contributor

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

  • Added package.json with scripts, dependencies (TypeScript, Jest, ESLint), and project metadata for a TypeScript/Node.js stack.
  • Added VS Code recommendations for Copilot extensions (.vscode/extensions.json) and workspace settings for Prettier formatting and TypeScript import style (.vscode/settings.json). [1] [2]
  • Introduced a GitHub Actions workflow (.github/copilot-setup-steps.yml) to automate setup, build, type-check, and test steps.

Copilot and Contributor Instructions

  • Provided both a detailed (.github/copilot-instructions-bloated.md) and a compressed, token-optimized (.github/copilot-instructions.md) Copilot instructions file, demonstrating instruction compression techniques. [1] [2]
  • Added on-demand prompt files for API design, testing standards, and deployment checklist, each specifying conventions and formats to be used in the project. [1] [2] [3]
  • Documented content exclusion patterns for Copilot context optimization in docs/content-exclusion-patterns.md.
  • Included a guide on compressing instructions ("caveman-style") with before/after examples in docs/caveman-instructions-examples.md.

Documentation and Project Structure

  • Overhauled README.md to explain the purpose of the repo, its structure, usage instructions, and the five rules of token optimization.

Sample Source Code and Tests

  • Added TypeScript models (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]
  • Implemented a sample Express server entry point in src/index.ts.
  • Provided a co-located test file for filterActiveUsersByLastLogin using 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]

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 thread src/utils/helpers.ts
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 thread src/config/database.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 thread src/routes/users.ts
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 thread package.json
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 thread src/index.ts
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;
@mickeygousset mickeygousset merged commit 33f675b into main Jun 4, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants