

Also from Kynth Studios


Also from Kynth Studios


Also from Kynth Studios
123456# IBM i — Copilot Instructions78> Applied automatically when working with RPG IV, RPGLE, CL, DDS display files, physical files, and logical files. Loaded alongside copilot-instructions.md.910---1112## RPG IV / RPGLE Free-Format Conventions1314Always write new RPG code in **fully free format** (no `/free`/`/end-free` directives required in RPGLE 7.2+). For legacy fixed-format code being modified, use the existing format; for new code within a legacy program, wrap additions in `/free` / `/end-free`.1516### Program Header Specification1718```rpgle19**FREE20// ============================================================21// Program : CUSTINQ22// Purpose : Customer inquiry — retrieve customer by ID23// Author : Development Team24// Date : 2024-11-0125// Called by: CSTMNU (interactive menu) / CUSTAPI (REST wrapper)26// ============================================================27Ctl-Opt DftActGrp(*No) ActGrp(*Caller) Option(*SrcStmt:*NoDebugIO);28Ctl-Opt BndDir('ENTBNDDIR');29Ctl-Opt Main(Main);30```3132### Mandatory `Ctl-Opt` Settings3334| Option | Required Value | Reason |35|--------|--------------|--------|36| `DftActGrp` | `*No` | Prevents legacy activation group; enables ILE error handling |37| `ActGrp` | `*Caller` or named group | Controls object lifecycle; do not use `*New` for service programs |38| `Option(*SrcStmt)` | Always set | Enables source-level debugging |39| `BndDir` | `'ENTBNDDIR'` (project binding directory) | Makes service programs available |4041### Procedure Prototype and Interface Pattern4243```rpgle44// ---- Prototype (in QRPGLESRC or copybook CUSTPRT) ----45Dcl-Pr GetCustomer ExtPgm('CUSTINQ');46 PCustomerId Char(10) Const;47 PCustomerName Char(50);48 PReturnCode Int(10);49End-Pr;5051// ---- Procedure Interface ----52Dcl-Pi Main;53 PCustomerId Char(10) Const;54 PCustomerName Char(50);55 PReturnCode Int(10);56End-Pi;57```5859### Data Structure Naming6061```rpgle62// Externally described data structure — preferred over hardcoded fields63Dcl-Ds CustRec ExtName('CUSTPF') Qualified;64End-Ds;6566// Program status data structure67Dcl-Ds PSDS PSDS Qualified;68 PgmName *Proc;69 StatusCode *Status;70 MsgId Char(7) Pos(40);71End-Ds;72```7374---7576## ILE Naming — Service Programs, Modules, Binding Directories7778| Object Type | Naming Convention | Example |79|-------------|------------------|---------|80| Module (`*MODULE`) | Verb+Noun, max 10 chars | `GETCUST`, `UPDORDER` |81| Program (`*PGM`) | Uppercase, max 10 chars, matches source member | `CUSTINQ`, `ORDPRC` |82| Service Program (`*SRVPGM`) | Domain prefix + function, max 10 chars | `CUSTSRV`, `PAYMTSRV` |83| Binding Directory (`*BNDDIR`) | Project + `BNDDIR` suffix | `ENTBNDDIR`, `FINBNDDIR` |84| Export list (`*.bnd`) | Same name as SRVPGM | `CUSTSRV.bnd` |8586### Creating a Service Program8788```cl89/* Create module */90CRTRPGMOD MODULE(ENTLIB/CUSTSRV) SRCFILE(QRPGLESRC) SRCMBR(CUSTSRV)91 DBGVIEW(*SOURCE) OPTIMIZE(*FULL) OUTPUT(*NONE)9293/* Create service program from module + export list */94CRTSRVPGM SRVPGM(ENTLIB/CUSTSRV) MODULE(ENTLIB/CUSTSRV)95 EXPORT(*SRCFILE) SRCFILE(QSRVSRC) SRCMBR(CUSTSRV)96 BNDDIR(ENTLIB/ENTBNDDIR) ACTGRP(*CALLER)9798/* Add to binding directory */99ADDBNDDIRE BNDDIR(ENTLIB/ENTBNDDIR) OBJ((ENTLIB/CUSTSRV *SRVPGM))100```101102---103104## CL Procedure Naming105106| Object | Convention | Example |107|--------|-----------|---------|108| CL Program (`*PGM`) | Action + domain + suffix `C` | `CRTCUSTC`, `PURGLOGSCC` |109| CL Command (`*CMD`) | Verb + Object, max 10 chars | `CRTCUST`, `PRGLOG` |110| CL Module in ILE | Same as program, used in SRVPGM | `JOBSTRC` |111112```cl113PGM PARM(&CUSTID &RETCODE)114115DCL VAR(&CUSTID) TYPE(*CHAR) LEN(10)116DCL VAR(&RETCODE) TYPE(*INT) LEN(4)117DCL VAR(&MSGID) TYPE(*CHAR) LEN(7)118119MONMSG MSGID(CPF0000 MCH0000) EXEC(GOTO CMDLBL(ERRHANDLE))120121/* Main logic */122CALL PGM(ENTLIB/CUSTINQ) PARM(&CUSTID *OMIT &RETCODE)123124GOTO CMDLBL(END)125126ERRHANDLE:127RCVMSG MSGTYPE(*EXCP) MSGID(&MSGID)128CHGVAR VAR(&RETCODE) VALUE(-1)129130END:131ENDPGM132```133134---135136## DDS Field Naming137138### Physical File (PF) Standards139140```dds141 A R CUSTREC TEXT('Customer Record')142 A CUSTID 10A COLHDG('Customer' 'ID')143 A CUSTNM 50A COLHDG('Customer' 'Name')144 A CUSTBAL 15P 2 COLHDG('Balance')145 A CRTDT 8S 0 COLHDG('Create' 'Date')146 A K CUSTID147```148149- Record format name: max 10 chars, uppercase, derived from file purpose150- Field names: max 10 chars, uppercase; no leading/trailing spaces151- All numeric monetary fields: packed decimal (`P`) with 2 decimal positions; never floating point152- Date fields: 8-digit numeric (`S 0` or `L` with `DATFMT`)153154### Logical File (LF) Standards155156```dds157 A R CUSTNMR PFILE(CUSTPF)158 A CUSTNM159 A CUSTID160 A CUSTBAL161 A K CUSTNM162 A K CUSTID163```164165Logical files: prefix with `L` or domain abbreviation; always specify `PFILE`.166167### Display File (DSPF) Standards168169- Record format naming: screen purpose + format code (e.g., `CUSTFMT1`, `CUSTMSGS`)170- Use `OVERLAY` indicator to avoid clearing screen between formats171- All user input fields must have `CHECK(RZ)` to strip leading zeros from numeric input172- Error messages through `ERRMSG` or `ERRMSGID` keywords, not hardcoded literals173174---175176## DB2 for i SQL Standards177178### Schema vs Library179180- In SQL context: use `SET SCHEMA` or fully qualify with schema name: `ENTSCHEMA.CUSTOMERS`181- In native I/O context: library used directly — `ENTLIB/CUSTPF`182- Do not mix native I/O and SQL on the same file within the same program without commit control alignment183184### Parameterized SQL — Forbidden Pattern185186```rpgle187// WRONG — EXECUTE IMMEDIATE with string concatenation is FORBIDDEN188SqlStmt = 'SELECT * FROM CUSTOMERS WHERE CUSTID = ''' + CustId + '''';189Exec Sql Execute Immediate :SqlStmt;190191// CORRECT — Parameterized with host variables192Exec Sql193 Select CustName, CustBal194 Into :WsCustName, :WsCustBal195 From ENTSCHEMA.CUSTOMERS196 Where CustId = :WsCustId;197```198199### SQL Error Handling200201```rpgle202Exec Sql203 Select CustName Into :WsCustName204 From ENTSCHEMA.CUSTOMERS205 Where CustId = :WsCustId;206207Select;208 When SqlCode = 0;209 // Success210 When SqlCode = 100;211 // Not found212 ReturnCode = 4;213 When SqlCode < 0;214 // SQL error215 ErrMsg = %Char(SqlCode);216 ReturnCode = 12;217EndSl;218```219220### JDBC vs Native I/O221222| Scenario | Recommended Access Method |223|----------|--------------------------|224| New REST API exposing IBM i data | JDBC via IBM Toolbox for Java (`jt400.jar`) |225| Existing RPG accessing PF directly | Native I/O (file declarations with F-specs) |226| Cross-platform reporting | SQL over JDBC — use `SELECT` with explicit column list |227| Batch record processing > 100K rows | Native I/O with sequential read for performance |228229---230231## IBM i Job Structure232233Every scheduled batch job must have a corresponding job description:234235```cl236/* Create Job Description */237CRTJOBD JOBD(ENTLIB/NIGHTBAT) JOBQ(ENTLIB/BATCHQ) TEXT('Nightly batch jobs')238 OUTQ(ENTLIB/BATOUTQ) LOG(4 0 *NOLIST) LOGCLPGM(*YES)239 INQMSGRPY(*SYSRPYL) ACGCDE('BATCHACG')240241/* Submit to batch */242SBMJOB CMD(CALL PGM(ENTLIB/NIGHTPRC)) JOB(NIGHTPRC) JOBD(ENTLIB/NIGHTBAT)243 JOBQ(ENTLIB/BATCHQ) MSGQ(*JOBD) HOLD(*NO)244```245246- Every production batch job must specify `JOBD` explicitly — never rely on defaults247- `LOG(4 0 *NOLIST)` for production; `LOG(4 0 *SECLVL)` for debugging248- High-volume jobs: specify subsystem routing entry to dedicated batch subsystem249250---251252## Error Handling — Monitor-On vs Message Handling253254### Preferred: Monitor-On in ILE RPG255256```rpgle257Monitor;258 Exec Sql259 Insert Into ENTSCHEMA.AUDIT_LOG260 Values (:WsAuditRec);261 On-Error 802;262 // Duplicate key — record already exists, acceptable263 ReturnCode = 0;264 On-Error;265 // All other SQL errors266 ReturnCode = 12;267 Leave;268EndMon;269```270271### CL Message Handling272273```cl274CALL PGM(ENTLIB/CUSTUPD) PARM(&CUSTID &RETCODE)275MONMSG MSGID(CPF9999) EXEC(DO)276 RCVMSG MSGTYPE(*EXCP) MSGID(&ERRMSGI) MSGDTA(&ERRMSGD)277 SNDPGMMSG MSGID(&ERRMSGI) MSGF(QCPFMSG) MSGDTA(&ERRMSGD) +278 TOPGMQ(*CALLER) MSGTYPE(*DIAG)279 CHGVAR VAR(&RETCODE) VALUE(-1)280ENDDO281```282283---284285## Conversion Patterns: RPG to REST API (IWS)286287IBM i Integrated Web Services (IWS) exposes RPG programs as REST endpoints without rewriting them:2882891. Program must use `EXTPGM` prototype with `CONST` input parameters and output parameters2902. Register in IWS: `WRKWTR` → Web Services → Create Web Service → Program call2913. XML/JSON payload mapping is auto-generated from parameter data types2924. For production: deploy via IWS deployment manager; version with `/v1/` prefix in URI2935. Authentication: IBM i digital certificate + HTTP Basic Auth at minimum; OAuth 2.0 preferred294295### RPG to Java Bridge (JDBC)296297```java298// IBM Toolbox for Java — jt400.jar299import com.ibm.as400.access.*;300301AS400 system = new AS400("ibmi-host.internal", "SVCUSER", credentials);302ProgramCall pgm = new ProgramCall(system);303pgm.setProgram("/QSYS.LIB/ENTLIB.LIB/CUSTINQ.PGM");304ProgramParameter[] params = {305 new ProgramParameter(AS400Text.toBytes("CUST0012345", 10)), // Input: customer ID306 new ProgramParameter(50), // Output: customer name307 new ProgramParameter(4) // Output: return code308};309pgm.setParameterList(params);310if (!pgm.run()) {311 throw new RuntimeException("CUSTINQ failed: " + pgm.getMessageList()[0].getText());312}313String custName = new AS400Text(50, system).toObject(params[1].getOutputData()).toString().trim();314```315316---317318## Modernization Risk Classification319320### Tight-Coupling Indicators — High Risk to Modernize321322| Indicator | Risk | Action |323|-----------|------|--------|324| `CALL` to > 5 external programs in procedure | HIGH | Map call graph before modernizing |325| Native I/O with no SQL equivalent | HIGH | Create SQL view before modernizing |326| `DSPATR(PR)` (protected display fields) driven by runtime data | MEDIUM | Map UI logic carefully |327| `INFDS` used for I/O error trapping | MEDIUM | Replace with structured error handling in Java |328| `%PARMS` (parameter count checking) for optional params | LOW | Implement method overloading in Java |329330### Data Dependency Analysis331332Before modernizing an RPG program, run:333334```sql335-- Find all physical files accessed by this program (via IFS catalog)336SELECT SYSTEM_TABLE_NAME, SYSTEM_TABLE_SCHEMA, TABLE_TYPE337FROM QSYS2.SYSTABLES338WHERE SYSTEM_TABLE_NAME IN (339 SELECT OBJECT_NAME FROM QSYS2.OBJECT_REFERENCES340 WHERE OBJECT_LIBRARY = 'ENTLIB' AND OBJECT_NAME = 'CUSTINQ' AND OBJECT_TYPE = '*PGM'341);342```343344See `.github/agents/modernization-expert.agent.md` for the IBM i modernization agent.345
One repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| doubts-suplab/eeik-bootstrap.clinerules/golden-rules.md · 1 | Cline rules | gitsecuritydo-not | 61/100 | today | |
| doubts-suplab/eeik-bootstrap.clinerules/project.md · 1 | Cline rules | teststylegit | 63/100 | today | |
| doubts-suplab/eeik-bootstrap.cursor/rules/architecture.mdc · 1 | Cursor rules | do-not | 52/100 | today | |
| doubts-suplab/eeik-bootstrap.cursor/rules/capabilities.mdc · 1 | Cursor rules | teststylegit | 58/100 | today | |
| doubts-suplab/eeik-bootstrap.cursor/rules/golden-rules.mdc · 1 | Cursor rules | gitsecuritydo-not | 61/100 | today | |
| doubts-suplab/eeik-bootstrap.cursor/rules/python.mdc · 1 | Cursor rules | lint-formatstyletypesapi+1 | 77/100 | today | |
| doubts-suplab/eeik-bootstrap.cursor/rules/security.mdc · 1 | Cursor rules | security | 39/100 | today | |
| doubts-suplab/eeik-bootstrap.github/copilot-instructions.md · 1 | Copilot instructions | lint-formatstyletesting-strategygit+2 | 54/100 | today | |
| doubts-suplab/eeik-bootstrap.github/instructions/a2a-protocol.instructions.md · 1 | Copilot instructions | styleagent-behaviour | 48/100 | today | |
| doubts-suplab/eeik-bootstrap.github/instructions/ai-governance.instructions.md · 1 | Copilot instructions | stylearchdo-notagent-behaviour | 61/100 | today | |
| doubts-suplab/eeik-bootstrap.github/instructions/angular.instructions.md · 1 | Copilot instructions | teststyletypestesting-strategy+4 | 69/100 | today | |
| doubts-suplab/eeik-bootstrap.github/instructions/architecture-governance.instructions.md · 1 | Copilot instructions | testlint-formatstylegit+4 | 65/100 | today | |
| doubts-suplab/eeik-bootstrap.github/instructions/autogen.instructions.md · 1 | Copilot instructions | typessecurityagent-behaviour | 50/100 | today | |
| doubts-suplab/eeik-bootstrap.github/instructions/aws-architecture.instructions.md · 1 | Copilot instructions | styletypessecurityperformance | 58/100 | today | |
| doubts-suplab/eeik-bootstrap.github/instructions/aws-data-ml-ai.instructions.md · 1 | Copilot instructions | deployment | 54/100 | today | |
| doubts-suplab/eeik-bootstrap.github/instructions/cdk-terraform.instructions.md · 1 | Copilot instructions | teststylearchtypes+2 | 96/100 | today | |
| doubts-suplab/eeik-bootstrap.github/instructions/cicd.instructions.md · 1 | Copilot instructions | stylesecuritydeploymentdo-not+1 | 65/100 | today | |
| doubts-suplab/eeik-bootstrap.github/instructions/containerisation.instructions.md · 1 | Copilot instructions | buildstylesecuritydo-not | 77/100 | today | |
| doubts-suplab/eeik-bootstrap.github/instructions/crewai.instructions.md · 1 | Copilot instructions | styleagent-behaviour | 48/100 | today | |
| doubts-suplab/eeik-bootstrap.github/instructions/data-engineering.instructions.md · 1 | Copilot instructions | teststyletypesgit+5 | 69/100 | today |
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| HerringtonDarkholme/megarepo.github/copilot-instructions.md · 17 | Copilot instructions | setupbuildtestlint-format+7 | 100/100 | 14 days ago | |
| louislam/uptime-kuma.github/copilot-instructions.md · 90k | Copilot instructions | setupbuildtestlint-format+9 | 100/100 | 14 days ago | |
| chihebnabil/lovable-boilerplate.github/instructions/global.instructions.md · 65 | Copilot instructions | buildlint-formatstylearch+4 | 100/100 | 14 days ago | |
| pytorch/pytorch.github/copilot-instructions.md · 102k | Copilot instructions | setupbuildteststyle+5 | 100/100 | 14 days ago | |
| JCodesMore/ai-website-cloner-template.github/copilot-instructions.md · 32k | Copilot instructions | buildlint-formatstylearch+3 | 97/100 | 7 days ago | |
| bagisto/bagisto.github/copilot-instructions.md · 28k | Copilot instructions | setupbuildteststyle+5 | 97/100 | 14 days ago | |
| hiyouga/LlamaFactory.github/copilot-instructions.md · 74k | Copilot instructions | setupbuildtestlint-format+5 | 97/100 | 13 days ago | |
| darkmatter/nixmac.github/copilot-instructions.md · 25 | Copilot instructions | setupbuildtestlint-format+8 | 96/100 | 14 days ago |
A badge carrying the measured quality of the strongest agent config file in this repository, out of 100. It reads from this index every time somebody loads your page, so it changes when the measurement changes and there is nothing to keep up to date. Free, no account, and the value is not something you or we can set by hand.
[](https://rulestack.kynth.studio/configs/doubts-suplab-eeik-bootstrap-github-instructions-ibmi-instructions)Would rather not hotlink us? Every badge is also served in shields.io’s endpoint schema, so shields renders the image and your readers never talk to our domain:
Published by Toolproof, the masthead over this index and eight others. The method behind the number is at toolproof.kynth.studio/methodology, and the whole thing is readable as JSON with no key at /api.