same prompt to Claude AI
I’ll read the PDF content you’ve shared and create a clear, practical workflow for forking a Gramps report and adding a Person filter option.
Here’s the simplified workflow:
Workflow: Fork a Gramps Report & Add a Person Filter
Step 1 — Copy the Existing Report Files
~/.local/share/gramps/gramps60/plugins/
└── MyFork/
├── myfork.py # copied from original report.py
└── myfork.gpr.py # copied from original report.gpr.py
Never edit the originals. Work only in your fork directory.
Step 2 — Update myfork.gpr.py
Change only the fields that identify the plugin. Leave reportclass, optionsclass, and category matching your new class names.
# myfork.gpr.py
from gramps.gen.plug._pluginreg import *
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
register(
REPORT,
id="MyForkReport", # unique ID — no spaces
name=_("My Forked Report"),
description=_("Fork of OriginalReport with person filter"),
version="1.0",
gramps_target_version="6.0",
status=STABLE,
fname="myfork.py", # must match your .py filename
authors=["Your Name"],
authors_email=["you@example.com"],
category=CATEGORY_TEXT,
require_active=False, # set True if filter needs active person
reportclass="MyForkReport", # must match class name in myfork.py
optionclass="MyForkOptions", # must match class name in myfork.py
report_modes=[REPORT_MODE_GUI, REPORT_MODE_CLI],
)
Step 3 — Update myfork.py — Imports
Add the imports needed for person filtering. The key additions are PersonOption and stdoptions.
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2025 Your Name
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# ------------------------
# Python modules
# ------------------------
import logging
# ------------------------
# Gramps modules
# ------------------------
from gramps.gen.plug.report import Report, MenuReportOptions, stdoptions
from gramps.gen.plug.menu import PersonOption
from gramps.gen.plug import docgen
from gramps.gen.const import GRAMPS_LOCALE as glocale
# ------------------------
# Gramps specific
# ------------------------
LOG = logging.getLogger(__name__)
_ = glocale.translation.gettext
Step 4 — Update the Options Class
Rename the class and add add_menu_options() with a PersonOption. If the original had no options class at all, create one from scratch inheriting MenuReportOptions.
#------------------------------------------------------------
#
# MyForkOptions
#
#------------------------------------------------------------
class MyForkOptions(MenuReportOptions):
"""Options for MyForkReport."""
def add_menu_options(self, menu: object) -> None:
"""
Add options to the menu for this report.
:param menu: The menu object to add options to.
"""
category_name = _("Report Options")
# Person filter — defaults to the active person in the database
pid = PersonOption(_("Filter Person"))
pid.set_help(_("The person the report is run for"))
menu.add_option(category_name, "pid", pid)
# Standard locale option
stdoptions.add_localization_option(menu, category_name)
def make_default_style(self, default_style: object) -> None:
"""
Define default paragraph styles.
:param default_style: The default StyleSheet to populate.
"""
# Title style
font = docgen.FontStyle()
font.set_size(18)
font.set_type_face(docgen.FONT_SANS_SERIF)
font.set_bold(True)
para = docgen.ParagraphStyle()
para.set_header_level(1)
para.set_alignment(docgen.PARA_ALIGN_CENTER)
para.set_font(font)
para.set_description(_("The style used for the title of the page."))
default_style.add_paragraph_style("MFR-Title", para)
# Normal style
font = docgen.FontStyle()
font.set_size(12)
font.set_type_face(docgen.FONT_SERIF)
para = docgen.ParagraphStyle()
para.set_font(font)
para.set_description(_("The style used for normal text"))
default_style.add_paragraph_style("MFR-Normal", para)
Style prefix rule: Change the 3-letter prefix (here MFR-) to something unique to your report to avoid collisions in Book report mode.
Step 5 — Update the Report Class
Rename the class, read the pid option in __init__, look up the Person object, then use it in write_report().
#------------------------------------------------------------
#
# MyForkReport
#
#------------------------------------------------------------
class MyForkReport(Report):
"""Forked report with a person filter option."""
def __init__(
self,
database: object,
options_class: MyForkOptions,
user: object,
) -> None:
"""
Initialize the report.
:param database: The Gramps database instance.
:param options_class: The options class instance for this report.
:param user: The User instance for interaction.
"""
Report.__init__(self, database, options_class, user)
# Read the person handle chosen in the options dialog
pid_option = options_class.menu.get_option_by_name("pid")
pid_value = pid_option.get_value() # returns a handle string
self.person = self.database.get_person_from_gramps_id(pid_value)
# Set report locale
self.set_locale(
options_class.menu.get_option_by_name("trans").get_value()
)
def write_report(self) -> None:
"""Write the report content to the document."""
if self.person is None:
LOG.warning("No person selected for report.")
return
name = self.person.get_primary_name().get_regular_name()
self.doc.start_paragraph("MFR-Title")
self.doc.write_text(self._("My Forked Report"))
self.doc.end_paragraph()
self.doc.start_paragraph("MFR-Normal")
self.doc.write_text(self._("Report for: %s") % name)
self.doc.end_paragraph()
# --- your original report logic goes here,
# scoped to self.person as needed ---
Step 6 — Install & Test
# Restart Gramps to pick up the new plugin, or use the Plugin Manager
# to reload without restarting (Tools > Plugin Manager > Reload)
# Command-line smoke test (no GUI needed):
gramps -O "YourFamilyTree" \
-a report \
-p name=MyForkReport,pid=I0001
Quick Reference — Key Differences from the Original
| What changed |
Original |
Fork |
| File names |
report.py / report.gpr.py |
myfork.py / myfork.gpr.py |
Plugin id |
original ID |
new unique string |
| Class names |
original names |
MyForkReport / MyForkOptions |
| Style prefix |
original (e.g. DBS-) |
new prefix (e.g. MFR-) |
| Options class base |
none or MenuReportOptions |
MenuReportOptions |
| Person option |
absent |
PersonOption("pid") added |
require_active |
depends |
set True if person must be active |
Commit Message Template (per Gramps AI guidelines)
Add person filter option to forked DbSummary report.
Fork of the built-in Database Summary report. Adds a PersonOption
so the report can be scoped to a single selected individual.
Generated-by: Claude Sonnet 4.6, Anthropic, claude-sonnet-4-6
Prompts: "Create a simplified workflow for forking an existing Gramps
report with no filtering options and adding a PersonOption to it,
following AGENTS.md and the report-writing tutorial."
Co-authored-by: Claude Sonnet 4.6, Anthropic <noreply@anthropic.com>