@ngocsangairvds/gc-kit 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -0
- package/bin/gc-kit.js +53 -0
- package/package.json +36 -0
- package/src/commands/init.js +37 -0
- package/src/lib/copyDir.js +105 -0
- package/src/lib/parseArgs.js +44 -0
- package/templates/.github/agents/DocumentApiWriter.agent.md +38 -0
- package/templates/.github/agents/JavaDev.agent.md +29 -0
- package/templates/.github/agents/TesterAPI.agent.md +48 -0
- package/templates/.github/agents/agents-skills/dev/debugging_Rules_Senior_Developer.md +116 -0
- package/templates/.github/agents/agents-skills/dev/feature_Development_Reusing_Codebase_Rules.md +62 -0
- package/templates/.github/agents/agents-skills/dev/java_Project_Development_Rules.md +80 -0
- package/templates/.github/agents/agents-skills/dev/knowledge/template/guidelines-template.md +328 -0
- package/templates/.github/agents/agents-skills/dev/knowledge/template/product-template.md +76 -0
- package/templates/.github/agents/agents-skills/dev/knowledge/template/structure-template.md +114 -0
- package/templates/.github/agents/agents-skills/dev/knowledge/template/tech-template.md +180 -0
- package/templates/.github/agents/agents-skills/dev/rule-base.md +16 -0
- package/templates/.github/agents/agents-skills/document-api-writer/api-documentation-template.md +173 -0
- package/templates/.github/agents/agents-skills/document-api-writer/rule.md +62 -0
- package/templates/.github/agents/agents-skills/document-api-writer/solution-design.md +155 -0
- package/templates/.github/agents/agents-skills/test/API_TestCase_Template.md +51 -0
- package/templates/.github/agents/agents-skills/test/API_Testing_Rules.md +66 -0
- package/templates/.github/prompts/create-knowledge.prompt.md +30 -0
package/README.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# gc-kit
|
|
2
|
+
|
|
3
|
+
A tiny CLI that copies a shared `.github/` folder into the current repository.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npx gc-kit init
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
### Options
|
|
12
|
+
|
|
13
|
+
- `--force` overwrite existing files under `.github/`
|
|
14
|
+
- `--dry-run` print what would be copied, without writing
|
|
15
|
+
- `--source <path>` copy from a custom `.github/` directory instead of the packaged template
|
|
16
|
+
- `--target <path>` copy into a different repo root (defaults to current directory)
|
|
17
|
+
|
|
18
|
+
Examples:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npx gc-kit init --dry-run
|
|
22
|
+
npx gc-kit init --force
|
|
23
|
+
npx gc-kit init --target /tmp/my-repo
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Development
|
|
27
|
+
|
|
28
|
+
From this repo:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
cd gc-kit
|
|
32
|
+
npm test
|
|
33
|
+
node ./bin/gc-kit.js init --dry-run
|
|
34
|
+
```
|
|
35
|
+
|
package/bin/gc-kit.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Note: use a file URL so ESM resolution works reliably in more tooling environments.
|
|
3
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
|
|
6
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = path.dirname(__filename);
|
|
8
|
+
const initModuleUrl = pathToFileURL(path.join(__dirname, '..', 'src', 'commands', 'init.js')).href;
|
|
9
|
+
const { initCommand } = await import(initModuleUrl);
|
|
10
|
+
|
|
11
|
+
const args = process.argv.slice(2);
|
|
12
|
+
const command = args[0];
|
|
13
|
+
|
|
14
|
+
async function main() {
|
|
15
|
+
if (!command || command === '-h' || command === '--help') {
|
|
16
|
+
printHelp(0);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (command === 'init') {
|
|
21
|
+
const exitCode = await initCommand(args.slice(1));
|
|
22
|
+
process.exitCode = exitCode;
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
console.error(`Unknown command: ${command}`);
|
|
27
|
+
printHelp(1);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function printHelp(exitCode) {
|
|
31
|
+
const text = `gc-kit - copy a shared .github/ folder into your repo
|
|
32
|
+
|
|
33
|
+
Usage:
|
|
34
|
+
npx gc-kit init [--force] [--dry-run] [--source <path>] [--target <path>]
|
|
35
|
+
|
|
36
|
+
Commands:
|
|
37
|
+
init Copy templates/.github -> <target>/.github
|
|
38
|
+
|
|
39
|
+
Options:
|
|
40
|
+
--force Overwrite existing files
|
|
41
|
+
--dry-run Print what would happen without writing
|
|
42
|
+
--source Source directory (defaults to packaged templates/.github)
|
|
43
|
+
--target Target directory (defaults to current working directory)
|
|
44
|
+
-h, --help Show help
|
|
45
|
+
`;
|
|
46
|
+
console.log(text);
|
|
47
|
+
process.exitCode = exitCode;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
main().catch((err) => {
|
|
51
|
+
console.error(err?.stack || String(err));
|
|
52
|
+
process.exitCode = 1;
|
|
53
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ngocsangairvds/gc-kit",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Copy a shared .github/ folder into the current repo.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Your Name <your.email@example.com>",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/yourusername/gc-kit.git"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"github",
|
|
13
|
+
"cli",
|
|
14
|
+
"template",
|
|
15
|
+
"copy",
|
|
16
|
+
"agents",
|
|
17
|
+
"prompts"
|
|
18
|
+
],
|
|
19
|
+
"type": "module",
|
|
20
|
+
"bin": {
|
|
21
|
+
"gc-kit": "./bin/gc-kit.js"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"bin/",
|
|
25
|
+
"src/",
|
|
26
|
+
"templates/",
|
|
27
|
+
"README.md"
|
|
28
|
+
],
|
|
29
|
+
"scripts": {
|
|
30
|
+
"test": "node ./scripts/smoke.mjs"
|
|
31
|
+
},
|
|
32
|
+
"engines": {
|
|
33
|
+
"node": ">=18"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
import { parseInitArgs } from '../lib/parseArgs.js';
|
|
4
|
+
import { copyDir } from '../lib/copyDir.js';
|
|
5
|
+
|
|
6
|
+
export async function initCommand(argv) {
|
|
7
|
+
const opts = parseInitArgs(argv);
|
|
8
|
+
|
|
9
|
+
const pkgRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../..');
|
|
10
|
+
const defaultSource = path.join(pkgRoot, 'templates', '.github');
|
|
11
|
+
|
|
12
|
+
const source = path.resolve(opts.source ?? defaultSource);
|
|
13
|
+
const targetRepoRoot = path.resolve(opts.target ?? process.cwd());
|
|
14
|
+
const target = path.join(targetRepoRoot, '.github');
|
|
15
|
+
|
|
16
|
+
const result = await copyDir({
|
|
17
|
+
sourceDir: source,
|
|
18
|
+
targetDir: target,
|
|
19
|
+
force: opts.force,
|
|
20
|
+
dryRun: opts.dryRun,
|
|
21
|
+
onLog: (line) => console.log(line)
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
if (result.errors.length > 0) {
|
|
25
|
+
console.error('\nErrors:');
|
|
26
|
+
for (const e of result.errors) console.error(`- ${e}`);
|
|
27
|
+
return 1;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (opts.dryRun) {
|
|
31
|
+
console.log(`\nDry-run complete. ${result.copiedFiles} file(s) would be copied.`);
|
|
32
|
+
} else {
|
|
33
|
+
console.log(`\nInit complete. Copied ${result.copiedFiles} file(s) into ${target}.`);
|
|
34
|
+
}
|
|
35
|
+
return 0;
|
|
36
|
+
}
|
|
37
|
+
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @param {object} params
|
|
6
|
+
* @param {string} params.sourceDir
|
|
7
|
+
* @param {string} params.targetDir
|
|
8
|
+
* @param {boolean} params.force
|
|
9
|
+
* @param {boolean} params.dryRun
|
|
10
|
+
* @param {(line: string) => void} params.onLog
|
|
11
|
+
*/
|
|
12
|
+
export async function copyDir({ sourceDir, targetDir, force, dryRun, onLog }) {
|
|
13
|
+
/** @type {string[]} */
|
|
14
|
+
const errors = [];
|
|
15
|
+
let copiedFiles = 0;
|
|
16
|
+
|
|
17
|
+
const srcStat = await safeStat(sourceDir);
|
|
18
|
+
if (!srcStat?.isDirectory()) {
|
|
19
|
+
return {
|
|
20
|
+
copiedFiles,
|
|
21
|
+
errors: [`Source directory does not exist or is not a directory: ${sourceDir}`]
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async function ensureDir(dirPath) {
|
|
26
|
+
if (dryRun) return;
|
|
27
|
+
await fs.mkdir(dirPath, { recursive: true });
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async function copyEntry(srcPath, rel) {
|
|
31
|
+
const dstPath = path.join(targetDir, rel);
|
|
32
|
+
|
|
33
|
+
const st = await safeLstat(srcPath);
|
|
34
|
+
if (!st) {
|
|
35
|
+
errors.push(`Missing source entry: ${srcPath}`);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (st.isSymbolicLink()) {
|
|
40
|
+
// Avoid copying symlinks to prevent unexpected path escapes.
|
|
41
|
+
errors.push(`Refusing to copy symlink: ${path.join(sourceDir, rel)}`);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (st.isDirectory()) {
|
|
46
|
+
onLog(`[dir] ${rel}`);
|
|
47
|
+
await ensureDir(dstPath);
|
|
48
|
+
const children = await fs.readdir(srcPath);
|
|
49
|
+
for (const name of children) {
|
|
50
|
+
await copyEntry(path.join(srcPath, name), path.join(rel, name));
|
|
51
|
+
}
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (st.isFile()) {
|
|
56
|
+
const dstStat = await safeStat(dstPath);
|
|
57
|
+
if (dstStat && !force) {
|
|
58
|
+
onLog(`[skip] ${rel} (exists; use --force)`);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
onLog(`${dstStat ? '[ovr]' : '[cpy]'} ${rel}`);
|
|
63
|
+
if (!dryRun) {
|
|
64
|
+
await ensureDir(path.dirname(dstPath));
|
|
65
|
+
await fs.copyFile(srcPath, dstPath);
|
|
66
|
+
// best-effort: keep executable bit if present
|
|
67
|
+
try {
|
|
68
|
+
const mode = st.mode & 0o777;
|
|
69
|
+
await fs.chmod(dstPath, mode);
|
|
70
|
+
} catch {
|
|
71
|
+
// ignore
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
copiedFiles += 1;
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
errors.push(`Unsupported file type: ${path.join(sourceDir, rel)}`);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
await ensureDir(targetDir);
|
|
82
|
+
const top = await fs.readdir(sourceDir);
|
|
83
|
+
for (const name of top) {
|
|
84
|
+
await copyEntry(path.join(sourceDir, name), name);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return { copiedFiles, errors };
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
async function safeStat(p) {
|
|
91
|
+
try {
|
|
92
|
+
return await fs.stat(p);
|
|
93
|
+
} catch {
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
async function safeLstat(p) {
|
|
99
|
+
try {
|
|
100
|
+
return await fs.lstat(p);
|
|
101
|
+
} catch {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export function parseInitArgs(argv) {
|
|
2
|
+
/** @type {{ force: boolean, dryRun: boolean, source?: string, target?: string }} */
|
|
3
|
+
const opts = { force: false, dryRun: false };
|
|
4
|
+
|
|
5
|
+
for (let i = 0; i < argv.length; i += 1) {
|
|
6
|
+
const a = argv[i];
|
|
7
|
+
|
|
8
|
+
if (a === '--force') {
|
|
9
|
+
opts.force = true;
|
|
10
|
+
continue;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
if (a === '--dry-run') {
|
|
14
|
+
opts.dryRun = true;
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (a === '--source') {
|
|
19
|
+
const v = argv[i + 1];
|
|
20
|
+
if (!v) throw new Error('--source requires a value');
|
|
21
|
+
opts.source = v;
|
|
22
|
+
i += 1;
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (a === '--target') {
|
|
27
|
+
const v = argv[i + 1];
|
|
28
|
+
if (!v) throw new Error('--target requires a value');
|
|
29
|
+
opts.target = v;
|
|
30
|
+
i += 1;
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (a === '-h' || a === '--help') {
|
|
35
|
+
// handled at top-level
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
throw new Error(`Unknown option: ${a}`);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return opts;
|
|
43
|
+
}
|
|
44
|
+
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: 'Document API Writer for this repo'
|
|
3
|
+
tools: ['insert_edit_into_file', 'create_file', 'run_in_terminal', 'get_terminal_output', 'get_errors', 'show_content', 'open_file', 'list_dir', 'read_file', 'file_search', 'grep_search', 'validate_cves', 'run_subagent', 'semantic_search']
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# DocumentApiWriter mode
|
|
7
|
+
|
|
8
|
+
You are a documentation specialist for writing API documents in this repository.
|
|
9
|
+
|
|
10
|
+
## Non-negotiable pre-flight (must happen BEFORE any writing)
|
|
11
|
+
|
|
12
|
+
Before you write, generate, or edit **any** API documentation content, you MUST:
|
|
13
|
+
1) Read `#file:.github/agents/agents-skills/document-api-writer/rule.md` **carefully and completely** (do not skip any section, including small notes and bullet points).
|
|
14
|
+
2) Read `#file:.github/agents/agents-skills/document-api-writer/solution-design.md` **carefully and completely** (do not skip any section).
|
|
15
|
+
3) Use those rules to guide what you produce.
|
|
16
|
+
|
|
17
|
+
If any of these files can’t be found, you must stop and re-check the repo structure; do not proceed.
|
|
18
|
+
|
|
19
|
+
## Template requirement (mandatory)
|
|
20
|
+
|
|
21
|
+
- When producing API documentation, you MUST base the output on:
|
|
22
|
+
- `#file:.github/agents/agents-skills/document-api-writer/api-documentation-template.md`
|
|
23
|
+
- The template structure must be followed fully; no section should be omitted unless the user explicitly asks to remove it.
|
|
24
|
+
- Fill placeholders with project-appropriate content; if information is missing, explicitly mark it as “TBD” and list the questions needed.
|
|
25
|
+
|
|
26
|
+
## Output location (mandatory)
|
|
27
|
+
|
|
28
|
+
- When you create or update API documentation, you MUST place the document as a Markdown file under:
|
|
29
|
+
- `#file:.github/agents/agents-skills/documents/`
|
|
30
|
+
- If the `documents/` folder does not exist, create it.
|
|
31
|
+
- Use clear, kebab-case filenames (e.g., `api-<feature>-v1.md`).
|
|
32
|
+
|
|
33
|
+
## Writing style & quality gates
|
|
34
|
+
|
|
35
|
+
- Focus on **Why / What / High-level How**; avoid low-level implementation details.
|
|
36
|
+
- Include decisions with options considered and trade-offs when relevant.
|
|
37
|
+
- Ensure consistency and traceability across tables/diagrams/text.
|
|
38
|
+
- Before finishing: re-check that the output maps to the template sections and that you followed the rules in `rule.md`.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Java development agent for this repo.
|
|
3
|
+
tools: ['insert_edit_into_file', 'create_file', 'run_in_terminal', 'get_terminal_output', 'get_errors', 'open_file', 'list_dir', 'read_file', 'file_search', 'grep_search', 'validate_cves', 'run_subagent', 'semantic_search']
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# JavaDev mode
|
|
7
|
+
|
|
8
|
+
You are a Java/Spring Boot programming agent working in this repository.
|
|
9
|
+
|
|
10
|
+
## Non-negotiable pre-flight (must happen BEFORE any code changes)
|
|
11
|
+
|
|
12
|
+
Before you modify, create, or delete **any** code/config file, you MUST:
|
|
13
|
+
1) Enumerate and read **all** markdown files under `.github/agents/agents-skills/dev/` (the `dev` folder), including `rule-base.md` and any other rule/prompt markdown files (including nested folders like `knowledge/`).
|
|
14
|
+
2) Read them **carefully and completely** — do not skip **any** part, even small sections such as notes, subheadings, examples, footnotes, or single bullet points.
|
|
15
|
+
3) Apply those rules when planning, editing, testing, and responding.
|
|
16
|
+
|
|
17
|
+
If you cannot find those files, you MUST stop and re-check the repo structure; do not proceed with edits until they are read.
|
|
18
|
+
|
|
19
|
+
## Working style
|
|
20
|
+
|
|
21
|
+
- Prefer small, safe changes that keep public APIs stable.
|
|
22
|
+
- Always gather enough context (search + targeted file reads) before editing.
|
|
23
|
+
- After edits: run `get_errors` on touched files, then run the fastest relevant build/test command (prefer Maven unit tests for this repo).
|
|
24
|
+
- Be security-conscious: never print secrets; avoid network calls unless explicitly requested.
|
|
25
|
+
|
|
26
|
+
## Quality gates before finishing
|
|
27
|
+
|
|
28
|
+
- Build or tests are green (or failures are clearly explained and unrelated, with a minimal repro).
|
|
29
|
+
- No new lint/type/compile errors are introduced.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: 'API test-case writer & runner for this repo'
|
|
3
|
+
tools: ['insert_edit_into_file', 'create_file', 'run_in_terminal', 'get_terminal_output', 'get_errors', 'show_content', 'open_file', 'list_dir', 'read_file', 'file_search', 'grep_search', 'validate_cves', 'run_subagent', 'semantic_search']
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# TesterAPI mode
|
|
7
|
+
|
|
8
|
+
You are a senior API tester agent for this repository.
|
|
9
|
+
|
|
10
|
+
## Non-negotiable pre-flight (must happen BEFORE writing or testing)
|
|
11
|
+
|
|
12
|
+
Before you generate a test case document or run any API test, you MUST:
|
|
13
|
+
1) Read the relevant API documentation file(s) referenced by the user under:
|
|
14
|
+
- `#file:.github/agents/agents-skills/documents/`
|
|
15
|
+
Read them carefully and completely; do not skip any section.
|
|
16
|
+
2) Read and follow the testing rules:
|
|
17
|
+
- `#file:.github/agents/agents-skills/test/API_Testing_Rules.md`
|
|
18
|
+
3) Use the test case template when generating any test-case document:
|
|
19
|
+
- `#file:.github/agents/agents-skills/test/API_TestCase_Template.md`
|
|
20
|
+
|
|
21
|
+
If any required file cannot be found, stop and re-check the repo structure; do not proceed.
|
|
22
|
+
|
|
23
|
+
## Test case generation (mandatory)
|
|
24
|
+
|
|
25
|
+
When asked to create test cases for an API:
|
|
26
|
+
- Generate the test case documentation in Markdown **based on** `API_TestCase_Template.md`.
|
|
27
|
+
- Ensure coverage includes (as applicable): happy path, negative, boundary, security, and basic compatibility checks (per `API_Testing_Rules.md`).
|
|
28
|
+
- Save the generated document under:
|
|
29
|
+
- `#file:.github/agents/agents-skills/test/test-case/`
|
|
30
|
+
- Use clear, kebab-case filenames, e.g. `tc-<api-name>-<endpoint>.md`.
|
|
31
|
+
|
|
32
|
+
## API execution using curl (mandatory when user asks to test an endpoint)
|
|
33
|
+
|
|
34
|
+
When the user asks to test a specific API endpoint:
|
|
35
|
+
1) Locate the corresponding test-case document in `#file:.github/agents/agents-skills/test/test-case/`.
|
|
36
|
+
2) Execute **all** test cases in that document using `curl` in the terminal.
|
|
37
|
+
- Include headers/auth exactly as specified.
|
|
38
|
+
- Capture HTTP status and response body.
|
|
39
|
+
- If auth/token/test data is required but not provided, mark the case as Blocked and clearly state what’s missing.
|
|
40
|
+
3) Report results:
|
|
41
|
+
- A table of each test case with: expected vs actual, PASS/FAIL/BLOCKED.
|
|
42
|
+
- Identify inconsistencies between the API documentation and actual behavior.
|
|
43
|
+
- If the result indicates that a prior agent’s output is wrong (e.g., incorrect doc, wrong assumptions, wrong test steps), explicitly call that out: which agent/artifact is incorrect and why.
|
|
44
|
+
|
|
45
|
+
## Output constraints
|
|
46
|
+
|
|
47
|
+
- Do not invent endpoints, headers, tokens, or request/response schemas.
|
|
48
|
+
- If the documentation is incomplete, clearly list the missing info and proceed only with what can be verified.
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# Debugging Rules & Practices (Senior Developer Guide)
|
|
2
|
+
|
|
3
|
+
## Rule 0: Never Guess
|
|
4
|
+
- Guessing is the slowest way to debug.
|
|
5
|
+
- Always collect evidence before making changes.
|
|
6
|
+
- Avoid random code changes without understanding the issue.
|
|
7
|
+
|
|
8
|
+
## 1. Identify Bug Type Quickly
|
|
9
|
+
Within the first minute, determine:
|
|
10
|
+
- Does the bug happen always or intermittently?
|
|
11
|
+
- Does it occur in production only?
|
|
12
|
+
- Is it related to data, timing, concurrency, or environment?
|
|
13
|
+
|
|
14
|
+
Correct classification reduces debugging time significantly.
|
|
15
|
+
|
|
16
|
+
## 2. Reproduce the Bug
|
|
17
|
+
- A bug that cannot be reproduced is not ready to be fixed.
|
|
18
|
+
- Reproduce using the same:
|
|
19
|
+
- Input
|
|
20
|
+
- User
|
|
21
|
+
- Data
|
|
22
|
+
- Environment
|
|
23
|
+
- If reproduction is not possible, rely on logs and traces instead of code changes.
|
|
24
|
+
|
|
25
|
+
## 3. Find the Entry Point
|
|
26
|
+
- Identify the exact API, job, event, or scheduler where the bug starts.
|
|
27
|
+
- Begin debugging from:
|
|
28
|
+
- Controller
|
|
29
|
+
- Message consumer
|
|
30
|
+
- Scheduled job
|
|
31
|
+
- Follow the execution flow step by step.
|
|
32
|
+
|
|
33
|
+
## 4. Narrow the Scope
|
|
34
|
+
- Reduce the search space aggressively.
|
|
35
|
+
- Techniques:
|
|
36
|
+
- Temporarily comment out unrelated code
|
|
37
|
+
- Bypass branches
|
|
38
|
+
- Mock external services
|
|
39
|
+
- Fix input values
|
|
40
|
+
- Goal: reduce thousands of lines to a small suspect area.
|
|
41
|
+
|
|
42
|
+
## 5. Strategic Logging
|
|
43
|
+
- Do not spam logs.
|
|
44
|
+
- Log decision points and state changes.
|
|
45
|
+
- Log:
|
|
46
|
+
- Input values
|
|
47
|
+
- State before and after changes
|
|
48
|
+
- Branches taken
|
|
49
|
+
- Avoid logging inside large loops.
|
|
50
|
+
|
|
51
|
+
## 6. Prefer Debugger Over Logs
|
|
52
|
+
- Use breakpoints to inspect real runtime values.
|
|
53
|
+
- Step through complex logic.
|
|
54
|
+
- Watch variables and conditions closely.
|
|
55
|
+
- Especially effective for:
|
|
56
|
+
- Complex conditionals
|
|
57
|
+
- Loops
|
|
58
|
+
- Unexpected branches
|
|
59
|
+
|
|
60
|
+
## 7. Common Hard Bug Scenarios
|
|
61
|
+
|
|
62
|
+
### 7.1 Production-only Bugs
|
|
63
|
+
Common causes:
|
|
64
|
+
- Different data
|
|
65
|
+
- Timezone issues
|
|
66
|
+
- Configuration mismatch
|
|
67
|
+
- Concurrency
|
|
68
|
+
Actions:
|
|
69
|
+
- Compare configs
|
|
70
|
+
- Inspect real production data
|
|
71
|
+
- Enable temporary controlled logging
|
|
72
|
+
|
|
73
|
+
### 7.2 Intermittent Bugs
|
|
74
|
+
Usually caused by:
|
|
75
|
+
- Race conditions
|
|
76
|
+
- Missing transactions
|
|
77
|
+
- Cache inconsistency
|
|
78
|
+
Check:
|
|
79
|
+
- Synchronization
|
|
80
|
+
- Transaction boundaries
|
|
81
|
+
- Cache eviction policies
|
|
82
|
+
|
|
83
|
+
### 7.3 Logic Looks Correct but Fails
|
|
84
|
+
Suspect:
|
|
85
|
+
- Incorrect assumptions
|
|
86
|
+
- Missing edge cases
|
|
87
|
+
- Null or default values
|
|
88
|
+
|
|
89
|
+
## 8. Debugging Checklist
|
|
90
|
+
- [ ] Can the bug be reproduced?
|
|
91
|
+
- [ ] Is the input correct?
|
|
92
|
+
- [ ] Is the data as expected?
|
|
93
|
+
- [ ] Which code branch is executed?
|
|
94
|
+
- [ ] Are there side effects?
|
|
95
|
+
- [ ] Is concurrency involved?
|
|
96
|
+
- [ ] Is caching involved?
|
|
97
|
+
- [ ] Are environment configs identical?
|
|
98
|
+
|
|
99
|
+
## 9. After Fixing the Bug
|
|
100
|
+
|
|
101
|
+
### 9.1 Add Tests
|
|
102
|
+
- Create test cases that reproduce the bug.
|
|
103
|
+
- Prevent regression.
|
|
104
|
+
|
|
105
|
+
### 9.2 Root Cause Analysis
|
|
106
|
+
- Identify why the bug existed.
|
|
107
|
+
- Determine which rule or assumption failed.
|
|
108
|
+
- Decide if refactoring is necessary.
|
|
109
|
+
|
|
110
|
+
### 9.3 Improve the System
|
|
111
|
+
- Add meaningful logs.
|
|
112
|
+
- Strengthen validation.
|
|
113
|
+
- Improve monitoring and alerts.
|
|
114
|
+
|
|
115
|
+
## Core Debugging Mindset
|
|
116
|
+
The bug is not stupid. The assumption is.
|
package/templates/.github/agents/agents-skills/dev/feature_Development_Reusing_Codebase_Rules.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Feature Development Rules: Reusing Existing Codebase
|
|
2
|
+
|
|
3
|
+
## 1. Mandatory Codebase Review
|
|
4
|
+
- Always review existing code before implementing a new feature.
|
|
5
|
+
- Do not start coding until similar logic has been searched and evaluated.
|
|
6
|
+
- Skipping codebase review leads to duplicated logic and technical debt.
|
|
7
|
+
|
|
8
|
+
## 2. Reasons to Read Existing Code
|
|
9
|
+
- Avoid reinventing existing solutions.
|
|
10
|
+
- Understand implicit business rules embedded in code.
|
|
11
|
+
- Preserve architectural consistency.
|
|
12
|
+
- Reuse or extend existing components properly.
|
|
13
|
+
|
|
14
|
+
## 3. How a Senior Developer Reviews Codebase
|
|
15
|
+
|
|
16
|
+
### Step 1: Identify Entry Points
|
|
17
|
+
- Review related Controllers or APIs.
|
|
18
|
+
- Understand request-to-response flow.
|
|
19
|
+
|
|
20
|
+
### Step 2: Search for Similar Features
|
|
21
|
+
- Search by domain keywords.
|
|
22
|
+
- Check enums, statuses, and database tables.
|
|
23
|
+
- Review services with similar responsibilities.
|
|
24
|
+
|
|
25
|
+
### Step 3: Focused Reading
|
|
26
|
+
Prioritize:
|
|
27
|
+
- Business logic
|
|
28
|
+
- Validation rules
|
|
29
|
+
- Transaction boundaries
|
|
30
|
+
- Integrations with external systems
|
|
31
|
+
|
|
32
|
+
Skip:
|
|
33
|
+
- Boilerplate code
|
|
34
|
+
- Simple getters/setters
|
|
35
|
+
- Trivial mappings
|
|
36
|
+
|
|
37
|
+
### Step 4: Evaluate Reusability
|
|
38
|
+
- Does the existing logic follow Single Responsibility Principle?
|
|
39
|
+
- Can it be reused without increasing coupling?
|
|
40
|
+
- Should it be refactored into a shared component?
|
|
41
|
+
|
|
42
|
+
## 4. When NOT to Reuse Existing Code
|
|
43
|
+
- Code is overly complex or unreadable.
|
|
44
|
+
- Code has heavy side effects.
|
|
45
|
+
- Code lacks tests and is risky to reuse.
|
|
46
|
+
- Reuse would increase coupling or break abstraction.
|
|
47
|
+
- Logic is coincidentally similar but belongs to a different domain.
|
|
48
|
+
|
|
49
|
+
## 5. Team Rules for Feature Development
|
|
50
|
+
- Every Pull Request must state:
|
|
51
|
+
- What code was reused, or
|
|
52
|
+
- Why reuse was not possible.
|
|
53
|
+
- Copy-paste logic is strictly prohibited.
|
|
54
|
+
- Refactoring should be discussed and agreed upon before reuse.
|
|
55
|
+
|
|
56
|
+
## 6. Senior Developer Mindset
|
|
57
|
+
- Write code for long-term maintainability, not just task completion.
|
|
58
|
+
- Respect existing code but do not blindly depend on it.
|
|
59
|
+
- Prefer consistency and clarity over clever implementations.
|
|
60
|
+
|
|
61
|
+
## Core Principle
|
|
62
|
+
Before writing new code, verify whether similar logic already exists.
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# Java Project Development Rules (Senior-Level)
|
|
2
|
+
|
|
3
|
+
## 1. Coding Convention & Clean Code
|
|
4
|
+
- Follow Java Code Convention and Google Java Style.
|
|
5
|
+
- Class names: PascalCase
|
|
6
|
+
- Method/variable names: camelCase
|
|
7
|
+
- Constants: UPPER_SNAKE_CASE
|
|
8
|
+
- Methods should not exceed 30–40 lines.
|
|
9
|
+
- One method = one responsibility.
|
|
10
|
+
- Avoid magic numbers; use constants.
|
|
11
|
+
- Avoid deep nested conditionals (>3 levels).
|
|
12
|
+
- Avoid boolean flags that make methods unclear.
|
|
13
|
+
|
|
14
|
+
## 2. Architecture & Layered Design
|
|
15
|
+
- Controller: handle HTTP request/response only.
|
|
16
|
+
- Service: business logic only.
|
|
17
|
+
- Repository: data access only.
|
|
18
|
+
- Never expose Entity directly; use DTOs.
|
|
19
|
+
- Controller must not access Repository directly.
|
|
20
|
+
|
|
21
|
+
## 3. Performance & Scalability
|
|
22
|
+
- Avoid database queries inside loops.
|
|
23
|
+
- Fix N+1 query problems.
|
|
24
|
+
- Always use pagination for list APIs.
|
|
25
|
+
- Proper database indexing (WHERE, JOIN, ORDER BY).
|
|
26
|
+
- Cache data that is read-heavy and rarely changes.
|
|
27
|
+
- Avoid unnecessary object creation in hot paths.
|
|
28
|
+
|
|
29
|
+
## 4. Exception Handling
|
|
30
|
+
- Do not catch generic Exception.
|
|
31
|
+
- Use domain-specific custom exceptions.
|
|
32
|
+
- Use global exception handling.
|
|
33
|
+
- Return clear error codes and messages.
|
|
34
|
+
- Logging rules:
|
|
35
|
+
- ERROR: system failure
|
|
36
|
+
- WARN: abnormal business state
|
|
37
|
+
- INFO: main application flow
|
|
38
|
+
|
|
39
|
+
## 5. Logging & Observability
|
|
40
|
+
- Use SLF4J + Logback.
|
|
41
|
+
- Include requestId / traceId in logs.
|
|
42
|
+
- Never log sensitive data (passwords, tokens).
|
|
43
|
+
- Avoid logging inside large loops.
|
|
44
|
+
|
|
45
|
+
## 6. Transaction Management
|
|
46
|
+
- @Transactional should be used at Service layer.
|
|
47
|
+
- Avoid calling transactional methods within the same class.
|
|
48
|
+
- Use readOnly transactions for read operations.
|
|
49
|
+
- Understand propagation and isolation levels.
|
|
50
|
+
|
|
51
|
+
## 7. Security Rules
|
|
52
|
+
- Validate all input at system boundaries.
|
|
53
|
+
- Never trust client-side data.
|
|
54
|
+
- Do not expose stack traces to clients.
|
|
55
|
+
- Do not decode JWT in Controllers.
|
|
56
|
+
- Authorization should be handled via filters/interceptors.
|
|
57
|
+
|
|
58
|
+
## 8. Testing & Quality Control
|
|
59
|
+
- Business logic must have unit tests.
|
|
60
|
+
- Avoid excessive mocking.
|
|
61
|
+
- Cover:
|
|
62
|
+
- Happy path
|
|
63
|
+
- Edge cases
|
|
64
|
+
- Error cases
|
|
65
|
+
- Enforce minimum test coverage (e.g. 70%).
|
|
66
|
+
- No critical issues in static analysis tools.
|
|
67
|
+
|
|
68
|
+
## 9. Dependency & Technical Debt Management
|
|
69
|
+
- Do not add dependencies without clear justification.
|
|
70
|
+
- Every dependency increases maintenance cost.
|
|
71
|
+
- Address technical debt incrementally each sprint.
|
|
72
|
+
|
|
73
|
+
## 10. Team & Code Review Rules
|
|
74
|
+
- Keep pull requests small and focused.
|
|
75
|
+
- Every PR must have a clear description.
|
|
76
|
+
- Code review focuses on improvement, not blame.
|
|
77
|
+
- Share knowledge through reviews.
|
|
78
|
+
|
|
79
|
+
## Core Mindset
|
|
80
|
+
Readable > Maintainable > Correct > Performant
|