to select ↑↓ to navigate
AI Etiquettes

AI Etiquettes

General Development Guidelines (Extremely important to enforce)

  1. Don't start function names with _underscore without any good reason (clutters the codebase)
# Bad
_get_items()
# Good
get_items()
  1. Use snake_case always in Python and JS don't use PascalCase
# Bad
GetItems()
# Good
get_items()
  1. No need for AI generated comments which don't add value (extra token wastage)
  2. Comments must explain WHY, not WHAT.
  3. Don't add comment if not required
# Bad
def get_dn_items(self):
"""This function fetches the items of delivery note"""
# Good
def get_dn_items(self):

# Bad 
#function to fetch invoice
# Good
#Prevent duplicate webhook invoices because PayU retries callbacks

# Never commit this type of garbage
/**
 * PHASE 2 — Poll until client answers (call status = connected).
 * Returns true if connected, false if not within attempts.
 * NOTE: Adjust the condition to match your API's "client answered" field.
**/

# =========================================================
# SMARTFLO HEADER BUILDER
# =========================================================
  1. Use meaning full/complete names for variables (it makes the code much more readable and helps LLM during parsing )
# Bad
const r = frappe.call(...) 
# Good
const response = frappe.call(...)

# Bad
const ps_info =... 
# Good
const packing_slip_info = ...

# Notice we changed ps_info to packing_slip_info which makes it much more understandable
# Bad
for i in ss_items
# Good
for item in salary_slip_items
  1. Use async/await functions in Desk JS don't use callback (nested functions eats tokens fast)
# Bad
frappe.call({
    method: "bwh_integration.api.bwh_login",
    freeze: true,
    freeze_message: "Logging in to BWH...",
    callback: function(r) {
        if (r.message && r.message.status === "success") {
            frappe.msgprint({
                title: "Success",
                message: "BWH login successful!",
                indicator: "green"
            });
            frm.reload_doc();
        }
    }
});

# Good
const response = await frappe.call({
    method: "bwh_integration.api.bwh_login",
    freeze: true,
    freeze_message: "Logging in to BWH...",})

if (response.message && response.message.status === "success") {
    frappe.msgprint({
        title: "Success",
        message: "BWH login successful!",
        indicator: "green"
    });
    frm.reload_doc();
}

Ways of development banned in BWH

  1. Avoid overriding DocType classes unless absolutely necessary.
  2. Never override DocType Class if Frappe changes base your system will break
  3. Prefer hooks, events, or server scripts.

Claude.md / Agents.md

Here is the link to claude.md that you should include in your projects root folder. It contains guardrails, common patterns that llms should follow.

Last updated 1 month ago
Was this helpful?
Thanks!