The smart bacteria could be the first medical use of a form of synthetic biology popularized by Synlogic cofounder and MIT professor James Collins starting in 2000. That year, Collins, taking his cue from electronics, constructed what’s essentially a toggle switch in E. coli—a circuit involving two genes that could flip-flop between states. It was nifty demonstration, and soon after, Princeton scientists announced they’d made a fluorescent bacterium that could flash on and off.

The idea was to program cells to carry out all kinds of new and useful functions. It proved irresistible—there have been countless experts panels, a TED Talk, and an international student competition.

But Synlogic’s plan for a genetically modified pill is one of the first concrete medical applications of such ideas. It involves deleting and adding several genes to a harmless strain of E. coli, the gut bacterium, so that it develops an unquenchable appetite for ammonia, formed from the nitrogen we get from eating protein.

Normally, extra nitrogen is turned into urea and we just pee it away. But some people can’t process it fast enough. They end up instead with ammonia levels that can be toxic enough to kill newborns and in kids and adults can cause delirium and angry behavior. Synlogic’s E. coli would take ammonia and turn it into arginine, a harmless amino acid.

A person would probably swallow a capsule once a day containing about 100 billion bacteria, says J.C. Gutierrez, the company’s CEO. The company has so far raised $70 million, including from Atlas Venture, the investment firm which also assembled the startup's founding team.

It’s not just rare diseases being targeted with redesigned bacteria. Startups like Ernest Pharmaceuticals, recently formed by University of Massachusetts professor Neil Forbes, plan to fight cancer using salmonella, a bacterium best known for causing food poisoning that also has a habit of congregating in tumors.

Forbes thinks the germs can be programmed to recognize they’re in a tumor and release anti-cancer drugs too toxic to be given as an injection.

Previously, one European company, ActoGenix, tested pills containing genetically modified bacteria, but no GM germ pill has yet gone on sale, and the idea remains novel enough that there’s no agreement on what to call such medicines. The U.S. Food and Drug Administration has designated them as “living biotherapeutic products.”

Currently, as many as eight to 10 GM bugs are awaiting a green light from the FDA for early testing in the U.S., estimates Yamil Hernandez, cofounder of Trayer Biotherapeutics, a startup in Maryland that intends to engineer a yogurt bacteria, lactobacillus, to consume phenylalanine, an ingredient in milk, nuts, and Coke Zero and other diet sodas that some people can’t digest. Hernandez says a germ designed to metabolize it could be sprinkled as a powder on food.

“It’s like hungry, hungry hippo, just with a very strong preference for phenylalanine,” he says.

Using bacteria as a treatment isn’t new to medicine. The vaccine against tuberculosis is made with weakened germs. And the U.S. probiotics market—those pills and yogurts at health food stores containing healthy gut bacteria—is worth $3.5 billion.

But no one is quite sure how to regulate a GM pill whose contents are both alive and likely to end up in toilet bowls. Gutierrez says in some cases, depending on how the germ is modified, the U.S. Environmental Protection Agency may have to sign off in addition to the FDA.

One risk is that bacteria can exchange DNA with one another, which means companies’ genetic alterations could end up in a completely different organism. In practice, scientists say organisms with engineered genomes stand little chance against their wild bacteria siblings. The germs usually die off and their genetic cargo goes extinct.

Synlogic says its germs have some additional features programmed into the genome that make them safer. Gutierrez says the ammonia-eating program will turn on only in a low-oxygen environment like the human gut. It’s also dependent on a nutrient, thymidine, that’s not found at high levels in the digestive tract. He says that because of this, the germs will divide only once before dying.