llamacppctl/example_user_prompts/coding_02_refactor.md
dschlueter f193acf032 docs: add example system/user prompts for prose, speeches, and code
Add example_system_prompts/ (prose, speeches, coding) and matching
example_user_prompts/ (four user prompts per domain, one file each so they
run directly via --prompt-file), plus a README mapping the pairs and the run
command against the default model.

Also refine the three system prompts: separate narrative register from
character speech and add a length default (prose); add a duration→word-count
rule, spoken-language guidance, a no-invented-evidence rule, and a salutation
note (speeches); fix the mangled numbered list and add a language default,
a no-invented-APIs rule, and clearer output ordering (coding).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-07 19:56:26 +02:00

659 B

Analysiere den folgenden Python-Code, benenne seine Schwächen und schreibe ihn robust und wartbar um. Gib danach eine kurze Begründung der wichtigsten Änderungen und ein paar pytest-Beispieltests.

import sqlite3

conn = sqlite3.connect('users.db')

def get_user(name):
    cur = conn.execute("SELECT * FROM users WHERE name = '" + name + "'")
    return cur.fetchone()

def add_user(name, age):
    try:
        conn.execute("INSERT INTO users VALUES ('" + name + "', " + str(age) + ")")
        conn.commit()
    except:
        pass

Achte besonders auf: SQL-Injection, Fehlerbehandlung, Ressourcen-/Verbindungsmanagement und Testbarkeit.