Skip to content

Instantly share code, notes, and snippets.

@heytulsiprasad
Created February 10, 2026 12:08
Show Gist options
  • Select an option

  • Save heytulsiprasad/195af37a1438556856a44731e2f86681 to your computer and use it in GitHub Desktop.

Select an option

Save heytulsiprasad/195af37a1438556856a44731e2f86681 to your computer and use it in GitHub Desktop.
Claude guidelines extracted from the University of Naples research paper who studied over 500k lines of human vs AI written code.

Code Quality Guard Rails

Security — AI's Blind Spot

AI-generated code contains 2-6x more security vulnerabilities than human code. Guard against these:

  • No hardcoded secrets. Never embed API keys, passwords, tokens, or credentials in source code. Use environment variables or secret managers.
  • No OS command construction from user input. Use parameterized APIs instead of string-concatenated shell commands.
  • No debug artifacts in committed code. Remove all System.out.println, printStackTrace, console.log debugging, and print() statements before finalizing. Use proper logging frameworks.
  • No cleartext sensitive data. Never log, transmit, or store passwords, tokens, or PII in plaintext.
  • Validate all external input. Sanitize user input, file paths, XML/JSON payloads — never trust it.

Unused Code — AI's Habit

AI models copy parameter signatures without using them. Don't leave dead code:

  • Every function parameter must be used in the body. If unused, remove it or prefix with _.
  • No unused imports, variables, or fields.
  • No placeholder classes with trivial or empty methods.

Complexity — Human's Habit

Human code trends toward maintainability debt. Keep it simple:

  • Max cyclomatic complexity per function: 10. Refactor if higher.
  • Max nesting depth: 3 levels. Extract helpers if deeper.
  • Catch specific exceptions, never bare except: or catch(Exception e).
  • Don't instantiate objects inside loops when they can be reused.
  • Prefer raise ... from for exception chaining (Python) to preserve traceability.

Shared Rules

  • Always specify file encoding in I/O operations.
  • Don't access protected/private members (_method) from outside the owning class.
  • Prefer proper logging over print statements at every stage, not just cleanup.
  • Review AI-generated code for security before merging — treat it as untrusted input.
@heytulsiprasad
Copy link
Author

heytulsiprasad commented Feb 10, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment