The judicial canons, as they are called, are not criminal statutes, but judges have been suspended and even removed for violating them.
Chief Justice Ronald D. Castille said the code was debated line by line by him and the other six justices on the high court until each provision won unanimous approval.
The justices adopted the code after two advisory committees issued reports on how Pennsylvania should update judicial rules. The upgrade in large part brings the code into agreement with a national model last updated by the American Bar Association in 2007.
The new code is silent about whether the ban on hiring relatives applies to family members already on the court payroll. While the code explicitly bans such hires in the future, Castille said the status of past hires was unresolved.
"We want to take a look at it," he said, adding, "If someone has been there for a while, to knock them off might be a little draconian."
Over the past year, Castille, a Republican, has been harshly critical of a fellow justice, Democrat Seamus P. McCaffery, over referral fees paid to McCaffery's wife, who is his chief judicial aide.
The FBI launched an investigation of these fees last year after The Inquirer reported that McCaffery's wife had been paid numerous fees by law firms over the last decade for referring clients to the firms.
Lawyers for McCaffery have said he and his wife, Lise Rapaport, had done nothing wrong.
Castille's wife, Susan, also serves as his top judicial aide. She had been working for the court system before their marriage.
The new code says judges "shall avoid nepotism, favoritism, and unnecessary appointments." The old one said judges should only appoint "on the basis of merit, avoiding favoritism." The old one did not contain the word nepotism.
The change was praised Wednesday by Lynn Marks, executive director of Pennsylvanians for Modern Courts, a group that advocates for judicial reform.
"Judges must be seen as fair and impartial in all aspects of their jobs," Marks said. "And when family members are hired - even when they are extremely well qualified - the public perception is one of favoritism."
In another major change, the new code says judges should disqualify themselves in cases in which lawyers before them have given campaign donations big enough to "raise a reasonable concern" about their ability to be fair.
This change brings Pennsylvania into line with a 2009 U.S. Supreme Court decision that ordered the chief justice of West Virginia to recuse himself from a $50 million case against a coal company whose chief executive had spent $3 million to help elect him.
The ABA's model code recommends that the state impose a set dollar figure that would trigger disqualification, but the Pennsylvania justices decided not to.
Some critics have said that some lawyers might scheme to give a sum just over a firm amount to knock an unwanted judge out of a case.
Judge Anne E. Lazarus of Superior Court, who headed one of the committees that studied how to overhaul the code, said the authors made the right call.
"Any time you have a hard figure, someone can give $1 more or $1 less than that figure," she said. "We felt that a hard-and-fast rule was not the best."
The new rule requiring judges to step down from for-profit corporate boards, except those of family-owned businesses, also is in line with the model code.
Philadelphia lawyer Abraham C. Reich, who served as cochair of the other advisory panel on updating the judicial code, noted that news accounts had spotlighted an instance in which the president judge of Carbon County also served on the board of the county's largest bank.
Reich called the dual roles "ridiculous."
"This is now prohibited," he said. "I think that is a positive development in enhancing the image of the judiciary in the eyes of the public."